From 7fc8c3703741f94c556cb2331a9ba37a9c339f2c Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Mon, 1 Jun 2026 22:12:03 +0300 Subject: [PATCH] reset cypress database --- frontend/rabbi_gerzi/cypress.config.mjs | 22 +++++++++++++++++++++ frontend/rabbi_gerzi/cypress/support/e2e.ts | 8 ++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/frontend/rabbi_gerzi/cypress.config.mjs b/frontend/rabbi_gerzi/cypress.config.mjs index d215a17..6717c51 100644 --- a/frontend/rabbi_gerzi/cypress.config.mjs +++ b/frontend/rabbi_gerzi/cypress.config.mjs @@ -1,6 +1,25 @@ +import { execFileSync } from 'node:child_process' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' import { defineConfig } from 'cypress' import createBundler from '@bahmutov/cypress-esbuild-preprocessor' +const configDirectory = dirname(fileURLToPath(import.meta.url)) +const backendDirectory = resolve(configDirectory, '../../backend') + +function resetDatabase() { + execFileSync( + 'php', + ['artisan', 'migrate:fresh', '--seed', '--force'], + { + cwd: backendDirectory, + stdio: 'inherit', + }, + ) + + return null +} + export default defineConfig({ e2e: { baseUrl: 'http://localhost:5173', @@ -11,6 +30,9 @@ export default defineConfig({ screenshotOnRunFailure: false, setupNodeEvents(onEvent) { onEvent('file:preprocessor', createBundler()) + onEvent('task', { + resetDatabase, + }) }, }, }) diff --git a/frontend/rabbi_gerzi/cypress/support/e2e.ts b/frontend/rabbi_gerzi/cypress/support/e2e.ts index 9b15a88..986240d 100644 --- a/frontend/rabbi_gerzi/cypress/support/e2e.ts +++ b/frontend/rabbi_gerzi/cypress/support/e2e.ts @@ -1,3 +1,7 @@ -// Loaded automatically before every spec file in cypress/e2e/. -// Intentionally minimal - add shared commands here when needed. +beforeEach(() => { + cy.task('resetDatabase') + cy.clearCookies() + cy.clearLocalStorage() +}) + export {}