forked from ing-bank/lion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
web-test-runner.config.mjs
64 lines (60 loc) · 1.63 KB
/
web-test-runner.config.mjs
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
58
59
60
61
62
63
64
import fs from 'fs';
import { playwrightLauncher } from '@web/test-runner-playwright';
const devMode = process.argv.includes('--dev-mode');
const packages = fs
.readdirSync('packages')
.filter(
dir => fs.statSync(`packages/${dir}`).isDirectory() && fs.existsSync(`packages/${dir}/test`),
)
.map(dir => ({ name: dir, path: `packages/${dir}/test` }))
.concat(
fs
.readdirSync('packages/ui/components')
.filter(
dir =>
fs.statSync(`packages/ui/components/${dir}`).isDirectory() &&
fs.existsSync(`packages/ui/components/${dir}/test`),
)
.map(dir => ({ name: dir, path: `packages/ui/components/${dir}/test` })),
);
/**
* @type {import('@web/test-runner').TestRunnerConfig['testRunnerHtml']}
*
*/
const testRunnerHtml = testRunnerImport =>
`
<html>
<head>
<script src="/node_modules/@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js"></script>
<script type="module" src="${testRunnerImport}"></script>
</head>
</html>
`;
export default {
nodeResolve: { exportConditions: [devMode && 'development'] },
coverageConfig: {
report: true,
reportDir: 'coverage',
threshold: {
statements: 95,
functions: 95,
branches: 95,
lines: 95,
},
},
testFramework: {
config: {
timeout: '5000',
},
},
testRunnerHtml,
browsers: [
playwrightLauncher({ product: 'firefox', concurrency: 1 }),
playwrightLauncher({ product: 'chromium' }),
playwrightLauncher({ product: 'webkit' }),
],
groups: packages.map(pkg => ({
name: pkg.name,
files: `${pkg.path}/**/*.test.js`,
})),
};