Skip to content

Commit 4a96a1b

Browse files
committed
add setup and teardown scripts
1 parent 57e2249 commit 4a96a1b

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

testing/e2e/playwright.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const browsers: { target: BrowserTarget; use: Project['use'] }[] = [
2626
] as const;
2727

2828
export default defineConfig({
29+
globalSetup: path.resolve(import.meta.dirname, 'src/global/global.setup.ts'),
30+
globalTeardown: path.resolve(import.meta.dirname, 'src/global/global.teardown.ts'),
2931
maxFailures: 1,
3032
outputDir: path.resolve(import.meta.dirname, '.playwright/output'),
3133
projects: [
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as fs from 'node:fs';
2+
3+
import type { FullConfig } from '@playwright/test';
4+
5+
import { AUTH_STORAGE_DIR } from '../helpers/constants';
6+
7+
export default function setup(_config: FullConfig) {
8+
if (!fs.existsSync(AUTH_STORAGE_DIR)) {
9+
fs.mkdirSync(AUTH_STORAGE_DIR, { recursive: true });
10+
}
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as fs from 'node:fs';
2+
3+
import { AUTH_STORAGE_DIR } from '../helpers/constants';
4+
5+
export default function teardown() {
6+
if (fs.existsSync(AUTH_STORAGE_DIR)) {
7+
fs.rmSync(AUTH_STORAGE_DIR, { force: true, recursive: true });
8+
}
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import * as path from 'node:path';
2+
3+
export const AUTH_STORAGE_DIR = path.resolve(import.meta.dirname, '../../.playwright/auth');

0 commit comments

Comments
 (0)