-
Notifications
You must be signed in to change notification settings - Fork 40
/
web-test-runner.config.mjs
73 lines (66 loc) · 2.09 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
import {
chromeLauncher,
summaryReporter,
defaultReporter,
} from "@web/test-runner";
import { exec } from "child_process";
import failOnly from "./test/lib/fail-only.mjs";
let config = {
testRunnerHtml: (testFramework) => `
<!DOCTYPE html>
<html>
<head>
<script src="/node_modules/chai/chai.js"></script>
<script src="/node_modules/chai-dom/chai-dom.js"></script>
<script>
should = chai.should();
window.useMoveBefore = ${process.env.USE_MOVE_BEFORE};
</script>
<script src="/test/lib/utilities.js"></script>
<script src="/node_modules/sinon/pkg/sinon.js"></script>
<script type="module" src="/node_modules/p-wait-for/index.js"></script>
<script type="module">
import pWaitFor from 'p-wait-for';
window.waitFor = pWaitFor;
</script>
<script src="/src/idiomorph.js"></script>
<script>Idiomorph.defaults.twoPass = ${process.env.DEFAULT_TWO_PASS}</script>
<script src="/node_modules/htmx.org/dist/htmx.js"></script>
<script src="/src/idiomorph-htmx.js"></script>
<script src="/test/lib/morphdom.js"></script>
<script type="module" src="${testFramework}"></script>
</head>
<body>
<em>Work Area</em>
<hr/>
<pre id="work-area" hx-ext="morph">
Output Here...
</pre>
</body>
</html>
`,
nodeResolve: true,
coverage: true,
coverageConfig: {
include: ["src/**/*"],
},
files: "test/*.js",
plugins: [failOnly],
reporters: [summaryReporter(), defaultReporter()],
};
if (process.env.USE_MOVE_BEFORE) {
// configure chrome to use a custom profile directory we control
config.browsers = [
chromeLauncher({
launchOptions: { args: ["--user-data-dir=test/chrome-profile"] },
}),
];
exec(
[
"rm -rf test/chrome-profile", // clear profile out from last run
"mkdir -p test/chrome-profile", // create from scratch
`echo '{"browser":{"enabled_labs_experiments":["atomic-move@1"]}}' > test/chrome-profile/Local\\ State`, // enable experiment
].join(" && "),
);
}
export default config;