-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathweb-test-runner.config.mjs
88 lines (79 loc) · 2.22 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import rollupReplace from "@rollup/plugin-replace";
import { esbuildPlugin } from "@web/dev-server-esbuild";
import { importMapsPlugin } from "@web/dev-server-import-maps";
import { fromRollup } from "@web/dev-server-rollup";
import { playwrightLauncher } from "@web/test-runner-playwright";
import { puppeteerLauncher } from "@web/test-runner-puppeteer";
import parseArgs from "minimist";
import rollupLitCss from "rollup-plugin-lit-css";
const args = parseArgs(process.argv.slice(2), {
boolean: true,
});
let browsers = [
playwrightLauncher({ product: "chromium" }),
playwrightLauncher({ product: "firefox", concurrency: 1 }),
playwrightLauncher({ product: "webkit" }),
];
if (args.debug) {
browsers = [
puppeteerLauncher({
launchOptions: {
args: ["--no-sandbox"],
devtools: true,
headless: !!args.headless,
},
}),
];
}
const litCss = fromRollup(rollupLitCss);
const replace = fromRollup(rollupReplace);
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
files: "src/**/*.test.ts",
rootDir: "./",
nodeResolve: true,
port: 8765,
coverageConfig: {
include: ["src/**/*.ts"],
threshold: {
branches: 100,
statements: 100,
functions: 100,
lines: 100,
},
},
mimeTypes: {
"src/components/**/*.css": "js",
},
browsers,
plugins: [
/* Use mock icon file in tests except bl-icon.test itself. */
importMapsPlugin({
inject: {
importMap: {
imports: {
"/src/components/icon/bl-icon": "./src/utilities/icon-mock.ts",
},
scopes: {
"/src/components/icon/": {
"/src/components/icon/bl-icon": "./src/components/icon/bl-icon.ts",
},
},
},
},
}),
litCss({
include: ["src/components/**/*.css"],
}),
replace({
"preventAssignment": true,
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
}),
esbuildPlugin({ ts: true, target: "esnext" }),
],
testRunnerHtml: testFramework => `<html>
<head><link rel="stylesheet" href="./dist/themes/default.css"></head>
<body>
<script type="module" src="${testFramework}"></script>
</body>
</html>`,
});