-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathweb-test-runner.config.js
77 lines (75 loc) · 2.62 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
/*
* Copyright 2023 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
// eslint-disable-next-line import/no-extraneous-dependencies
import { defaultReporter } from '@web/test-runner';
// eslint-disable-next-line import/no-extraneous-dependencies
import { junitReporter } from '@web/test-runner-junit-reporter';
export default {
nodeResolve: true,
coverage: true,
reporters: [
defaultReporter(),
junitReporter(),
],
testFramework: {
type: 'mocha',
config: {
timeout: 10000,
},
},
coverageConfig: {
report: true,
reportDir: 'coverage',
exclude: [
'test/fixtures/**',
'node_modules/**',
'.rum/**',
'src/index.js',
],
},
files: [
'test/**/*.test.{html,js}',
'test/*.test.{html,js}',
],
middleware: [
async function emulateRUM(context, next) {
if (context.url.startsWith('/src/index.map.js')) {
await next();
context.body = context.body
.replace(/navigator\.sendBeacon/g, 'fakeSendBeacon');
return true;
} else if (context.url.startsWith('/.rum')) {
if (context.url.startsWith('/.rum/@adobe/helix-rum-js@%5E2/dist/')
|| context.url.startsWith('/.rum/@adobe/helix-rum-js@^2/dist/')
) {
context.url = '/node_modules/@adobe/helix-rum-js/dist/rum-standalone.js';
await next();
context.body = context.body
.replace(/const weight =/, 'const weight = 1 ||')
.replace(/navigator\.sendBeacon/g, 'fakeSendBeacon')
// eslint-disable-next-line no-template-curly-in-string
.replace('.rum/@adobe/helix-rum-enhancer@${enhancerVersion || \'^2\'}/src/index.js', 'src/index.map.js');
return true;
} else if (context.url.startsWith('/.rum/web-vitals')) {
context.url = '/node_modules/web-vitals/dist/web-vitals.iife.js';
await next();
return true;
} else if (context.url === '/.rum/1') {
// return a 201 response and do nothing
context.status = 201;
return true;
}
}
return next();
},
],
};