Attempting to seed my dynamodb table in a cy.task() using aws node sdk. The putItem promise resolves successfully and my database is updated but Cypress throws an error as finds a circular structure in the response ...
> TypeError: Converting circular structure to JSON
--> starting at object with constructor 'TLSSocket'
| property 'parser' -> object with constructor 'HTTPParser'
--- property 'socket' closes the circle
at JSON.stringify (<anonymous>)
at process.target._send (internal/child_process.js:778:25)
at process.target.send (internal/child_process.js:676:19)
at Object.send (/Users/redacted/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:34:27)
at /Users/redacted/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:53:20
If the promise resolves then cypress should allow the test to crack on and not error :)
here is my plugins/index.js
var AWS = require('aws-sdk');
AWS.config.update({region: 'eu-west-1'});
var credentials = new AWS.SharedIniFileCredentials({profile: 'myprofile'});
AWS.config.credentials = credentials;
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on('task', {
'seed:db' (data) {
var docClient = new AWS.DynamoDB.DocumentClient({apiVersion: '2012-08-10'});
promises = data.map(x=>{
var params = {
TableName: 'my-table',
Item: x
};
return docClient.put(params, function(err, response){
if (err) {
console.log("Put Item error");
} else {
console.log(`Put Item Success - ${x.name}`);
}
})
})
return promises
},
})
}
and the beforeEach in my test file....
beforeEach(function () {
cy.fixture('seed').then((seed)=>{
cy.task('seed:db', seed)
})
})
cypress 4.0.1
Node 12.16.1
osx Catalina 10.15.3
was being silly sorry
@ed-sparkes can you share what the solution was? I'm seeing the same behavior
Most helpful comment
@ed-sparkes can you share what the solution was? I'm seeing the same behavior