Repository navigation
Expand file tree
/
Copy pathweb-test-runner.config.mjs
More file actions
49 lines (47 loc) · 1.65 KB
/
Copy pathweb-test-runner.config.mjs
File metadata and controls
49 lines (47 loc) · 1.65 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
import { esbuildPlugin } from "@web/dev-server-esbuild";
// The built-in `a11ySnapshot` command only returns "interesting" nodes, which
// drops structural roles like radiogroup. This one returns the full tree so
// tests can assert the accessible name Chrome computes for any node.
function fullA11ySnapshotPlugin() {
return {
name: "full-a11y-snapshot-command",
async executeCommand({ command, session }) {
if (command !== "full-a11y-snapshot") return undefined;
if (session.browser.type !== "puppeteer") {
throw new Error(
`full-a11y-snapshot is not supported for ${session.browser.type}`
);
}
const page = session.browser.getPage(session.id);
return page.accessibility.snapshot({ interestingOnly: false });
},
};
}
export default {
files: "test/unit/**/*.test.ts",
// Prefer the "browser" export condition so browser-only builds of deps are
// used (e.g. nanoid, pulled in transitively by Web Awesome, whose default
// export targets Node's `node:crypto` and fails in the browser).
nodeResolve: {
exportConditions: ["browser", "import", "default"],
browser: true,
},
plugins: [
fullA11ySnapshotPlugin(),
esbuildPlugin({
ts: true,
// The plugin passes raw config to esbuild, which does not resolve
// extends. Read the shared compiler settings directly.
tsconfig: "./tsconfig.json",
// Vite sets this; the unit tests run through esbuild instead, and use
// the same browser mock as the dev server.
define: { "import.meta.env.DEV": "true" },
}),
],
testFramework: {
config: {
ui: "bdd",
timeout: 5000,
},
},
};