-
Notifications
You must be signed in to change notification settings - Fork 295
/
web-test-runner.config.mjs
48 lines (44 loc) · 1.61 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
import { litSsrPlugin } from '@lit-labs/testing/web-test-runner-ssr-plugin.js';
import { playwrightLauncher } from '@web/test-runner-playwright';
import { optimisedGlob } from 'providence-analytics/utils.js';
const config = {
shouldLoadPolyfill: !process.argv.includes('--no-scoped-registries-polyfill'),
shouldRunDevMode: process.argv.includes('--dev-mode'),
};
const groups = (
await optimisedGlob(['packages/*/test', 'packages/ui/components/**/test'], {
onlyDirectories: true,
})
) // @ts-expect-error [update-es-version-later]
.map(dir => ({ name: dir.split('/').at(-2), files: `${dir}/**/*.test.js` })); // .filter(({name}) => name === 'overlays');
/**
* @type {import('@web/test-runner').TestRunnerConfig['testRunnerHtml']}
*/
const testRunnerHtmlWithPolyfill = testRunnerImport =>
`
<html>
<head>
<script src="/node_modules/@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js"></script>
<script type="module" src="${testRunnerImport}"></script>
</head>
</html>
`;
export default {
nodeResolve: config.shouldRunDevMode ? { exportConditions: ['development'] } : true,
coverageConfig: {
report: true,
reportDir: 'coverage',
threshold: { statements: 95, functions: 95, branches: 95, lines: 95 },
},
testFramework: {
config: { timeout: '5000' },
},
testRunnerHtml: config.shouldLoadPolyfill ? testRunnerHtmlWithPolyfill : undefined,
browsers: [
playwrightLauncher({ product: 'firefox', concurrency: 1 }),
playwrightLauncher({ product: 'chromium' }),
playwrightLauncher({ product: 'webkit' }),
],
groups,
plugins: [litSsrPlugin()],
};