-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathweb-test-runner.config.js
116 lines (111 loc) · 3.7 KB
/
web-test-runner.config.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { fileURLToPath } from 'node:url';
import os from 'node:os';
import chalk from 'chalk';
import { defaultReporter } from '@web/test-runner';
import { esbuildPlugin } from '@web/dev-server-esbuild';
import { fromRollup } from '@web/dev-server-rollup';
import { playwrightLauncher } from '@web/test-runner-playwright';
import rollupPluginCommonjs from '@rollup/plugin-commonjs';
export default {
browsers: [
// https://github.com/modernweb-dev/web/issues/2588
playwrightLauncher(),
],
concurrency: process.env.CI ? os.cpus().length : os.cpus().length / 2,
coverage: true,
coverageConfig: {
include: ['src/**/*.ts'],
report: true,
exclude: [
// Juice not worth the squeeze. Testing this wouldn't add much given the
// test code would look more or less like the code that's under test.
// Testing whether the center of an element was clicked, for example, would
// require the same `Math.ceil(x + width / 2)` and `Math.ceil(y + height / 2)`
// calculations that are in the library itself.
'src/library/mouse.ts',
// Not much to test. Also untestable.
'src/library/shadow-root-mode.ts',
],
reportDir: 'dist/coverage',
threshold: {
statements: 100,
branches: 100,
functions: 100,
lines: 100,
},
},
files: [
'src/**/*.test.*.ts',
'src/**/*.test.ts',
'!**/eslint/**',
'!**/icons/**',
'!**/stylelint/**',
'!**/translations/**',
'!src/**/*.*.test.aria.ts',
'!src/**/*.*.test.visuals.ts',
'!src/**/*.test.aria.ts',
'!src/**/*.test.visuals.ts',
],
nodeResolve: {
browser: true,
// https://lit.dev/docs/tools/development#development-and-production-builds
exportConditions: ['production'],
},
plugins: [
// Some modules still use CommonJS-style exports. This plugin handles them.
//
// https://github.com/modernweb-dev/web/issues/1700#issuecomment-1059441615
fromRollup(rollupPluginCommonjs)({
include: ['**/node_modules/**'],
// The default, `true`, doesn't play well with Axe Core, which our
// `expect(host).to.be.accessible()` assertions use.
strictRequires: 'auto',
}),
esbuildPlugin({
ts: true,
// https://github.com/lit/lit/issues/3807#issuecomment-1513369439
tsconfig: fileURLToPath(new URL('tsconfig.json', import.meta.url)),
}),
],
reporters:
process.env.NODE_ENV === 'production'
? [defaultReporter()]
: [
defaultReporter(),
'lcov',
{
start() {
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.log(
`Code coverage report: ${chalk.bgBlue(
'http://localhost:8080',
)}\n`,
);
}
},
onTestRunStarted() {
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.log(
`Code coverage report: ${chalk.bgBlue(
'http://localhost:8080',
)}\n`,
);
}
},
},
],
testRunnerHtml(testFramework) {
return `<html>
<body>
<link href="./src/styles/fonts.css" rel="stylesheet">
<link href="./src/styles/variables/light.css" rel="stylesheet">
<link href="./src/styles/variables/dark.css" rel="stylesheet">
<link href="./src/styles/variables/miscellaneous.css" rel="stylesheet">
<link href="./src/styles/variables/system.css" rel="stylesheet">
<script type="module" src="${testFramework}"></script>
</body>
</html>`;
},
};