chore(tests): cleanup playwright configs

This commit is contained in:
moklick
2023-11-08 18:13:57 +01:00
parent d82a54fa5b
commit 434590543d
12 changed files with 18 additions and 27 deletions

View File

@@ -1 +0,0 @@
FRAMEWROK=svelte

View File

@@ -1,13 +1,4 @@
import { defineConfig } from '@playwright/test';
import { sharedConfigWithPort } from './playwright.shared.config';
const port = 3000;
export default defineConfig({
...sharedConfigWithPort(port),
webServer: {
command: 'cd ../../examples/react && pnpm run dev',
port,
reuseExistingServer: !process.env.CI,
},
});
export default defineConfig(sharedConfigWithPort({ port: 3000, framework: 'react' }));

View File

@@ -1,6 +1,11 @@
import { PlaywrightTestConfig, devices } from '@playwright/test';
export function sharedConfigWithPort(port: number): PlaywrightTestConfig {
type ConfigParams = {
port: number;
framework: string;
};
export function sharedConfigWithPort({ port, framework }: ConfigParams): PlaywrightTestConfig {
return {
testDir: './e2e',
/* Run tests in files in parallel */
@@ -21,6 +26,11 @@ export function sharedConfigWithPort(port: number): PlaywrightTestConfig {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
webServer: {
command: `pnpm --filter=${framework}-examples run dev --port ${port}`,
port,
reuseExistingServer: !process.env.CI,
},
/* Configure projects for major browsers */
projects: [

View File

@@ -1,13 +1,4 @@
import { defineConfig } from '@playwright/test';
import { sharedConfigWithPort } from './playwright.shared.config';
const port = 5173;
export default defineConfig({
...sharedConfigWithPort(port),
webServer: {
command: 'cd ../../examples/svelte && pnpm run dev --port 5173',
port: port,
reuseExistingServer: !process.env.CI,
},
});
export default defineConfig(sharedConfigWithPort({ port: 5173, framework: 'svelte' }));