【问题标题】:How to use aws credentials using cypress如何使用 cypress 使用 aws 凭证
【发布时间】:2021-01-19 23:06:44
【问题描述】:

在运行 cypress 测试时,我目前很难找到将我的 AWS 凭证集成到我的 cypress 测试中的方法。静态方法可以将您的凭据硬编码到 config.update 中。但是,我希望使用我的本地凭据选择更动态的方法。从节点执行成功创建临时凭据时,我设法编写了一个工作脚本。但坚持如何将凭证实施到赛普拉斯 AWS.config.update()

【问题讨论】:

    标签: javascript aws-sdk cypress aws-config aws-credentials


    【解决方案1】:

    通过使用赛普拉斯cy.task 只需在plugins/index.js on task 中定义您的 aws-sdk 命令并确保包含 AWS.config.update({region: *REGIONNAME*}) 并在浏览器测试中设置您的cy.task(doSomething)

    插件/index.js

    on('task', {
    
    getOrg(orgid) {
    var AWS = require("aws-sdk");
    AWS.config.update({region: *REGIONNAME*}
    
    //e.g AWS SDK command to get a organisation id from dynamodb
    
    Return *null or value or true etc*
     }
    }
    
    
    

    Cypress 测试示例 test.js

    orgid = 123;
    cy.task ("getOrg",orgid)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-11
      • 2018-06-03
      • 1970-01-01
      • 2021-09-09
      • 2019-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多