-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathweb-test-runner.config.mjs
More file actions
80 lines (69 loc) · 2.51 KB
/
Copy pathweb-test-runner.config.mjs
File metadata and controls
80 lines (69 loc) · 2.51 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { fileURLToPath } from 'node:url';
import { esbuildPlugin } from '@web/dev-server-esbuild';
import { defaultReporter } from '@web/test-runner';
import { playwrightLauncher } from '@web/test-runner-playwright';
/**
* Chromium reports the "ResizeObserver loop completed with undelivered
* notifications" condition as an uncaught exception with no associated
* `Error` object. Test code (see `suppressResizeObserverLoopError` in
* `utils.spec.ts`) can prevent it from failing a test via `window.onerror`,
* but web-test-runner's browser log collection picks the (error-less)
* exception up independently of that, printing it as a bare `null` line.
* This reporter strips those specific single-`null`-argument log entries
* before the default reporter prints anything, without hiding other,
* legitimate `console.*` output from tests.
*/
function filterBenignBrowserLogs() {
return {
reportTestFileResults({ sessionsForTestFile }) {
for (const session of sessionsForTestFile) {
session.logs = session.logs.filter(
(args) => !(args.length === 1 && args[0] === null)
);
}
},
};
}
/**
* Loads `assertion-errors.spec.ts` ahead of the test framework so that every
* test file gets the chai patch that keeps failed assertions on non-cloneable
* subjects (sinon spies, DOM nodes) reportable. See the module itself for the
* details.
*/
function testRunnerHtml(testFramework) {
return `<!DOCTYPE html>
<html>
<body>
<script type="module" src="/src/internals/testing/assertion-errors.spec.ts"></script>
<script type="module" src="${testFramework}"></script>
</body>
</html>`;
}
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
files: ['src/**/*.spec.ts'],
browsers: [playwrightLauncher({ product: 'chromium', headless: true })],
testRunnerHtml,
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
// esbuildTarget: 'auto',
/** Configure bare import resolve plugin */
nodeResolve: {
exportConditions: ['browser', 'production'],
},
coverageConfig: {
exclude: ['node_modules/**/*', '**/themes/**'],
},
testFramework: {
config: {
timeout: 3000,
},
},
reporters: [filterBenignBrowserLogs(), defaultReporter()],
plugins: [
esbuildPlugin({
ts: true,
tsconfig: fileURLToPath(new URL('./tsconfig.json', import.meta.url)),
}),
],
// See documentation for all available options
// https://modern-web.dev/docs/test-runner/cli-and-configuration/#configuration-file
});