Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
57 lines (54 loc) · 1.52 KB
/
Copy pathplaywright.config.ts
File metadata and controls
57 lines (54 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { readdirSync } from 'node:fs'
import path from 'node:path'
import { defineConfig, devices } from '@playwright/test'
const root = import.meta.dirname
const selectedTestDir = process.env.PLAYWRIGHT_TEST_DIR
const exampleDirs = selectedTestDir
? [path.resolve(selectedTestDir, '../..')]
: [
'react',
'preact',
'solid',
'angular',
'vue',
'svelte',
'lit',
'alpine',
'ember',
'octane',
].flatMap((framework) =>
readdirSync(path.join(root, 'examples', framework), {
withFileTypes: true,
})
.filter((entry) => entry.isDirectory())
.map((entry) => path.join(root, 'examples', framework, entry.name))
.sort(),
)
function projectName(exampleDir: string) {
return `${path.basename(path.dirname(exampleDir))}/${path.basename(exampleDir)}`
}
export default defineConfig({
// Nx runs one process per example. Each process owns its failure artifacts.
outputDir: path.join(
root,
'test-results',
selectedTestDir ? projectName(exampleDirs[0]!) : 'all',
),
testMatch: '**/*.spec.{ts,mts}',
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: 1,
timeout: 30_000,
expect: { timeout: 5_000 },
reporter: 'list',
use: {
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
},
projects: exampleDirs.map((exampleDir) => ({
name: projectName(exampleDir),
testDir: path.join(exampleDir, 'tests/e2e'),
use: { ...devices['Desktop Chrome'] },
})),
})