Repository navigation
Expand file tree
/
Copy pathweb-test.runner-config.mjs
More file actions
66 lines (65 loc) · 2.14 KB
/
Copy pathweb-test.runner-config.mjs
File metadata and controls
66 lines (65 loc) · 2.14 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
import { esbuildPlugin } from "@web/dev-server-esbuild";
import fg from "fast-glob";
import { playwrightLauncher } from "@web/test-runner-playwright";
// Packages run tests in parallel (at most three at once, as more overload
// the browsers on CI runners), so each package's test
// scripts pass a unique --port: design 8000, wes 8001, cloud registry 8002,
// tes 8003, service registry 8004, trs 8005, trs-filer 8006, drs 8007.
export default {
rootDir: ".",
files: "src/**/*.test.ts", // "default" group
concurrentBrowsers: 3,
nodeResolve: {
exportConditions: ["production", "default"],
},
testFramework: {
config: {
timeout: 3000,
retries: 1,
},
},
// With `--coverage` (as in CI): the coverage of the package's sources in
// Chromium (the only browser that reports it), written to
// `coverage/lcov.info` in the package, which CI uploads to Codecov
coverageConfig: {
include: ["src/**"],
exclude: ["**/*.test.ts", "**/node_modules/**"],
reportDir: "coverage",
reporters: ["lcov"],
},
plugins: [
esbuildPlugin({
ts: true,
target: "es2020",
// Lit decorators need the package's experimentalDecorators setting
// (relative to the working directory: run tests from the package)
tsconfig: "./tsconfig.json",
}),
],
browsers: [
playwrightLauncher({ product: "chromium" }),
playwrightLauncher({ product: "firefox" }),
playwrightLauncher({ product: "webkit" }),
],
testRunnerHtml: (testFramework) => `
<html lang="en-US">
<head></head>
<body>
<script>
window.process = {env: { NODE_ENV: "production" }}
</script>
<script type="module" src="${testFramework}"></script>
</body>
</html>
`,
// Create a named group for every test file to enable running single tests. If a test file is `form.test.ts`
// then you can run `npm run test -- --group form` to run only that component's tests.
groups: fg.sync("src/**/*.test.ts").map((path) => {
const groupName = path.match(/^.*\/(?<fileName>.*)\.test\.ts/).groups
.fileName;
return {
name: groupName,
files: path,
};
}),
};