/
web-test-runner.config.js
92 lines (78 loc) · 2.29 KB
/
web-test-runner.config.js
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
89
90
91
92
// @ts-check
import { esbuildPlugin } from '@web/dev-server-esbuild';
import { fromRollup } from '@web/dev-server-rollup';
import { sendKeysPlugin } from '@web/test-runner-commands/plugins';
import { resolveLocalFilesFromTypeScriptSources } from './plugins/resolve-local.js';
import { playwrightLauncher } from '@web/test-runner-playwright';
import _commonjs from '@rollup/plugin-commonjs';
import _graphql from '@rollup/plugin-graphql';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
const graphql = fromRollup(_graphql);
const commonjs = fromRollup(_commonjs);
const cjsIncludes = [
'**/fast-json-stable-stringify/index.js',
'**/graphql-tag/src/index.js',
'**/zen-observable/**/*.js',
'**/incremental-dom/dist/*cjs.js',
];
const rootDir = dirname(fileURLToPath(new URL(import.meta.url)));
/** @type {Partial<import('@web/test-runner').TestRunnerConfig>} */
export default ({
nodeResolve: {
extensions: ['.ts', '.mjs', '.js', '.css', '.graphql'],
},
browsers: [playwrightLauncher()],
rootDir,
files: [
'packages/!(create)/**/*.test.ts',
],
mimeTypes: {
'**/*.graphql': 'js',
},
coverageConfig: {
exclude: [
'_site/**/*',
'_site-dev/**/*',
'.vscode/**/*',
'.netlify/**/*',
'coverage/**/*',
'packages/**/*.test.{ts, js}',
'packages/lib/cuid.{ts, js}',
'**/node_modules/**/*',
'**/test/**/*',
'*__*-dev-server__*',
],
},
testRunnerHtml: testRunnerImport => `
<html>
<head>
<script>
// @ts-ignore: https://github.com/graphql/graphql-js/pull/2409
globalThis.process ??= { env: {} };
// suppress advertising
globalThis.__APOLLO_DEVTOOLS_GLOBAL_HOOK__ = () => void 0;
</script>
</head>
<body>
<script type="module">
import '${testRunnerImport}';
</script>
</body>
</html>
`,
plugins: [
resolveLocalFilesFromTypeScriptSources({ rootDir }),
graphql(),
commonjs({ include: cjsIncludes, ignoreDynamicRequires: false }),
esbuildPlugin({ ts: true }),
sendKeysPlugin(),
{
name: 'fake it for gluon',
resolveImport({ source }) {
if (source.endsWith('lit-html/lib/shady-render.js'))
return '../../lit-html/lit-html.js';
},
},
],
});