reset cypress database
This commit is contained in:
parent
df747d9c69
commit
7fc8c37037
2 changed files with 28 additions and 2 deletions
|
|
@ -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,
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue