question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reload existing active session

See original GitHub issue

What would you like?

After using function cy.session([value, value]), Cypress will fail to load an existing active session.

For my current setup I am running this in an after() block, but the same will happen even if added inside a test.

If I print cy.state(‘activeSessions’) the required session will be printed and is hydrated: true.

This will work if there is only 1 test being ran, but if there are multiple tests, it will error out with the below message.

No session is defined with the name
  ["value","value"]
In order to use cy.session(), provide a setup as the second argument:

cy.session(id, setup)

Why is this needed?

I need to access an existing session without being required to reproduce the entire login session again (session id, setup and validation), in order to avoid the possibility of creating a new session for the same details.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
emilyrohrboughcommented, Nov 17, 2022

I will say, if you are trying to determine if an ID has already been used to save a session, you can leverage Cypress.session.getActiveSession('ID'), but I still suggest moving this logic into your login logic.

0reactions
emilyrohrboughcommented, Nov 17, 2022

@alexniculae Session is closely tied to the concept of Test Isolation. There will be two modes of test isolation, on and off, with on being the new default mode. When test isolation is on, before each test, Cypress will:

  • clear the page by visiting about:blank
  • clear cookies
  • clear local storage
  • clear browser storage

When the browser context is cleared, it should behave as a “logout” on the client side. We do perform this before each test to enable easier debugging if an error goes wrong.

Is your setup & validate logic saving the session data before it’s ready to be saved and that is why you are trying to collect the remaining session data at the end of the test?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reload previously active sessions - UltraEdit
To enable the "Reload session previously open on startup", go to Options : Configuration : Sesssions. Click to enable the "Reload session previously...
Read more >
How to Reload or Change your current Shell? - Linux
Learn the basic steps to reload your Linux shell to apply your recent configurations changes. This post cover the POSIX exec builtin command...
Read more >
How do I reload a module in an active Julia session after an ...
If I close the current Julia session, start a new one, and type in using ctbTestModule , I now get the desired behaviour,...
Read more >
Reload a Linux user's group assignments without logging out
You can use the following command to send the command to all an existing Screen sessions: screen -S <session_name> -X at \# stuff...
Read more >
What effects does restarting sshd have on existing ssh ...
Existing sessions will remain active, using the pre-restart config. All new sessions will use the new config.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found