From 52fafd420b026e5b28b3cb048815aa471204088a Mon Sep 17 00:00:00 2001 From: Maxime Perrault Date: Wed, 18 Sep 2024 16:18:04 +0200 Subject: [PATCH] fix: add validate to e2e config --- frontend/cypress/support/e2e.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/cypress/support/e2e.ts b/frontend/cypress/support/e2e.ts index d6c511b710..341f71dd0a 100644 --- a/frontend/cypress/support/e2e.ts +++ b/frontend/cypress/support/e2e.ts @@ -46,7 +46,16 @@ beforeEach(() => { // We use a Cypress session to inject inject a Local Storage key // so that we can detect when the browser app is running in Cypress. // https://docs.cypress.io/faq/questions/using-cypress-faq#How-do-I-preserve-cookies--localStorage-in-between-my-tests - cy.session('cypress', () => { - window.localStorage.setItem('IS_CYPRESS', 'true') - }) + cy.session( + 'cypress', + () => { + window.localStorage.setItem('IS_CYPRESS', 'true') + }, + // https://www.cypress.io/blog/mistake-when-using-cy-session-and-how-to-solve-it + { + validate() { + window.localStorage.getItem('IS_CYPRESS') === 'true' + } + } + ) })