-
Notifications
You must be signed in to change notification settings - Fork 1
/
web-test-runner.config.js
45 lines (41 loc) · 1.2 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
import { defaultReporter } from '@web/test-runner';
import { greenwoodPluginTypeScript } from '@greenwood/plugin-typescript';
import { junitReporter } from '@web/test-runner-junit-reporter';
// create a direct instance of TypeScriptResource
const typeScriptResource = greenwoodPluginTypeScript()[0].provider({
context: {
projectDirectory: new URL(import.meta.url)
}
});
export default {
files: './src/**/*.spec.js',
nodeResolve: true,
mimeTypes: {
'**/*.ts': 'js'
},
coverage: true,
coverageConfig: {
reportDir: './reports'
},
reporters: [
defaultReporter({ reportTestResults: true, reportTestProgress: true }),
junitReporter({
outputPath: './reports/test-results.xml'
})
],
plugins: [{
name: 'transpile-typescript',
async transform(context) {
const { url } = context.request;
if (url.endsWith('.ts')) {
const response = await typeScriptResource.serve(new URL(`.${url}`, import.meta.url));
// https://github.com/ProjectEvergreen/greenwood/issues/661
const body = (await response.text()).replace(/\/\/# sourceMappingURL=module.js.map/, '');
return {
body,
type: 'js'
};
}
}
}]
};