2

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()

1 Answers1

-1

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.

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

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