DEV Community

Discussion on: Multi-Domain (Origin) Testing in Cypress

Collapse
 
muratkeremozcan profile image
Murat K Ozcan

cy.origin() is such a huge win! Can't wait to try it out with AWS Cognito login.

Why do we need the args in cy.session([email, password]..?

I definitely love order independence push in tests while using cy.session, it is the right thing to do, but having to re-login via session for every test is not very nice.

I will try to combo cy.origin with cy.session vs cypress-data-session (everything I wish cy.session was) and let you know how it goes.

Collapse
 
jordanpowell88 profile image
Jordan Powell

Thanks for the feedback Murat! The reason you need the args:

The args object is the only mechanism via which data may be injected into the callback, the callback is not a closure and does not retain access to the JavaScript context in which it was declared. Values passed into args must be serializable.

Essentially think of cy.session like you would an HTTP request. Any data you will need on either end of the request/response you need to pass in the request (which then gets serialized) so it needs passed in as an arg so that the callback function has a reference to. Hope that helps bring some clarification