Skip to content

Commit 91464e7

Browse files
committed
fix: Clear saved sessions in restoreState()
As in the comment, user sessions created between `saveState()` and `restoreState()` are not present in the database, but exist in the web server . Using them will create instabilities, so we clear them all to prevent session errors. Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent ed5d28c commit 91464e7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lib/commands/state.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ export function restoreState(snapshot: string = 'init') {
2020
runCommand(`rm -vfr ./data/*`)
2121
runCommand(`tar -xf '/var/www/html/data-${snapshot}.tar'`)
2222

23+
// Any user sessions created between saveState() and restoreState()
24+
// are not present in the database, but exist in the web server.
25+
// Using them leads to unknown behavior, so we clear them all to prevent session errors.
26+
Cypress.session.clearAllSavedSessions()
27+
2328
cy.log(`Restored snapshot ${snapshot}`)
2429
}

0 commit comments

Comments
 (0)