diff --git a/cypress.config.ts b/cypress.config.ts index 98ea63758cc..1e83c0b7f5d 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -68,6 +68,19 @@ export default defineConfig({ on('task', { removeDirectory }) + // This allows to store global data (e.g. the name of a snapshot) + // because Cypress.env() and other options are local to the current spec file. + const data = {} + on('task', { + setVariable({ key, value }) { + data[key] = value + return null + }, + getVariable({ key }) { + return data[key] ?? null + }, + }) + // Disable spell checking to prevent rendering differences on('before:browser:launch', (browser, launchOptions) => { if (browser.family === 'chromium' && browser.name !== 'electron') {