-
Notifications
You must be signed in to change notification settings - Fork 55
/
web-test-runner.config.js
58 lines (54 loc) · 1.85 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
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import {playwrightLauncher} from '@web/test-runner-playwright';
import {fakeCdnPlugin} from './test/fake-cdn-plugin.js';
import {startDevServer} from '@web/dev-server';
// For some tests we want a separate origin to use as the sandbox-base-url.
const separateOriginServer = await startDevServer({
config: {
rootDir: './',
nodeResolve: true,
},
});
// This plugin lets our tests discover the origin (this way we don't have to
// hard-code a port and assume it is available).
const separateOriginPlugin = () => ({
name: 'separate-origin-plugin',
executeCommand({command}) {
if (command === 'separate-origin') {
const {hostname, port} = separateOriginServer.config;
return `http://${hostname}:${port}/`;
}
},
});
// https://modern-web.dev/docs/test-runner/cli-and-configuration/
export default {
rootDir: './',
// Note this file list can be overridden by wtr command-line arguments.
files: ['test/**/*_test.js'],
nodeResolve: true,
browsers: [
playwrightLauncher({product: 'chromium'}),
playwrightLauncher({product: 'webkit'}),
playwrightLauncher({product: 'firefox'}),
],
concurrentBrowsers: Number(process.env.CONCURRENT_BROWSERS) || 2, // default 2
browserStartTimeout: 30000, // default 30000
testsStartTimeout: 20000, // default 10000
testsFinishTimeout: 120000, // default 20000
testFramework: {
// https://mochajs.org/api/mocha
config: {
ui: 'tdd',
timeout: '30000', // default 2000
},
},
plugins: [fakeCdnPlugin(), separateOriginPlugin()],
filterBrowserLogs: ({args}) =>
// This warning will always happen because we use the same local server for
// the elements and the service worker, and that's fine.
!args.join('').includes('executing with the same origin as its parent'),
};