-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cypress v14 fails to save session between files when using the cacheAccrossSpecs option #31130
Comments
@SaratogaHazel We do have some tests around this option, so likely there's something specific with your tests that we've missed. Can you try a couple of things?
|
* injectDocumentDomain: true
That fixed it.
From: Jennifer Shehane ***@***.***>
Sent: Tuesday, February 18, 2025 2:36 PM
To: cypress-io/cypress ***@***.***>
Cc: Greg "Le Grenouille" Patterson ***@***.***>; Mention ***@***.***>
Subject: [Ext:] Re: [cypress-io/cypress] Cypress v14 fails to save session between files when using the cacheAccrossSpecs option (Issue #31130)
[External Email]
@SaratogaHazel<https://github.com/SaratogaHazel> We do have some tests around this option, so likely there's something specific with your tests that we've missed. Can you try a couple of things?
* On Cypress 14, can you set injectDocumentDomain: true and let us know if this resolves the issue?
* Can you provide an example of what your code kind of looks like? What your calling in cy.session (without the keys) and then how you're calling that and when the cy.visit or any cy.origin calls happen?
-
Reply to this email directly, view it on GitHub<#31130 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AW35MCSPNUE5A57APPKQ2BT2QORU7AVCNFSM6AAAAABXMOCJLOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRWHE3TSMZTG4>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
[jennifer-shehane]jennifer-shehane left a comment (cypress-io/cypress#31130)<#31130 (comment)>
@SaratogaHazel<https://github.com/SaratogaHazel> We do have some tests around this option, so likely there's something specific with your tests that we've missed. Can you try a couple of things?
* On Cypress 14, can you set injectDocumentDomain: true and let us know if this resolves the issue?
* Can you provide an example of what your code kind of looks like? What your calling in cy.session (without the keys) and then how you're calling that and when the cy.visit or any cy.origin calls happen?
-
Reply to this email directly, view it on GitHub<#31130 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AW35MCSPNUE5A57APPKQ2BT2QORU7AVCNFSM6AAAAABXMOCJLOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRWHE3TSMZTG4>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
@SaratogaHazel This Can you provide an example of what your code kind of looks like? What your calling in cy.session (without the keys) and then how you're calling that and when the cy.visit or any cy.origin calls happen? |
Here is an example of my login script that uses the cy.session
```js
Cypress.Commands.add('LoginSession', (url) => {
cy.session(
'Login',
() => {
cy.visit(url)
cy.get('input[type="text"]').type(Cypress.env('username'))
cy.get('input[type="submit"]').click()
cy.get('input[type="password"]').type(Cypress.env('password'), {
log: false,
})
cy.get('input[type="submit"]').click()
cy.get('#sessions', { timeout: 90000 }).contains('Sessions')
cy.document().its('cookie').should('contain', Cypress.env('access_token'))
cy.getCookie(Cypress.env('access_token'))
.should('exist')
.then((c) => {
cy.wait(1000)
cy.log(`cookie: ${c.value}`)
window.localStorage.setItem('idToken', c.value)
Cypress.env({ idToken: c.value })
})
},
{
cacheAcrossSpecs: true,
}
)
})
```
|
@SaratogaHazel Are you calling |
Current behavior
I use the cy.session to run all of my tests which span multiple files. So I use the cacheAcrossSpecs: true option. When I upgraded to v14, the session worked for the first file, but didn't for all of the following files. When I moved back to 13.17.0 version, it all worked fine. I will have to wait for a fix before I can move to v14. So please look at fixing this.
Desired behavior
Allow the cacheAcrossSpecs: true to work in V14 so I can use the same login session for my tests that span more than on file.
Test code to reproduce
My code is confidential and requires login to use the cy.sessions command. I'm sure you have test code that tests this.
Cypress Version
14.0.2
Node version
v20.17.0
Operating System
Windows 11
Debug Logs
Other
No response
The text was updated successfully, but these errors were encountered: