Welcome to OverStack Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
in Technique[技术] by (71.8m points)

javascript - How to use aws credentials using cypress

I'm currently having difficulty finding a way to integrate my AWS credentials into my cypress tests when running cypress tests. The static approach works in hardcording your credentials into config.update . However I wish to opt for a more dynamic approach using my local credentials . I have managed to write a working script when executing from node successfully creates temp credentials. But stuck on how to implement the credentials into cypress AWS.config.update()

Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

By using Cypress cy.task Simply define your aws-sdk command in plugins/index.js on task and make sure to include AWS.config.update({region: *REGIONNAME*}) And set your cy.task(doSomething) in your browser test.


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 example test.js

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

Welcome to OverStack Developer Community-Open, Learning and Share