-
Notifications
You must be signed in to change notification settings - Fork 254
Expand file tree
/
Copy pathtest.js
More file actions
67 lines (61 loc) · 1.9 KB
/
test.js
File metadata and controls
67 lines (61 loc) · 1.9 KB
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
import IstanbulLibReport from 'istanbul-lib-report'
import IstanbulLibSourceMaps from 'istanbul-lib-source-maps'
import IstanbulReports from 'istanbul-reports'
import {
serveDir,
setupChromeConductor,
setupNodeConductor,
setupSourceModuleLoader,
setupToolboxTester,
} from '@ph.fritsche/toolbox'
const env = await serveDir('testenv')
const {cli, connectCoverageReporter} = await setupToolboxTester(
['src', 'tests'],
[
setupNodeConductor('Node, DTL10, React18', [
new URL('../testenv/node.js', import.meta.url),
new URL('./libs/dom10/index.bundle.js', env.url),
new URL('./libs/react18/index.bundle.js', env.url),
]),
setupNodeConductor('Node, DTL8, React17', [
new URL('../testenv/node.js', import.meta.url),
new URL('./libs/dom8/index.bundle.js', env.url),
new URL('./libs/react17/index.bundle.js', env.url),
]),
setupChromeConductor('Chrome, DTL10, React18', [
new URL('./browser.bundle.js', env.url),
new URL('./libs/dom10/index.bundle.js', env.url),
new URL('./libs/react18/index.bundle.js', env.url),
]),
],
[
await setupSourceModuleLoader({
globals: {
'@testing-library/dom': 'DomTestingLibrary',
'@testing-library/react': 'ReactTestingLibrary',
react: 'React',
'react-dom': 'ReactDom',
},
}),
],
{
setExitCode: false,
},
)
connectCoverageReporter(async map => {
const sourceStore = IstanbulLibSourceMaps.createSourceMapStore()
const reportContext = IstanbulLibReport.createContext({
coverageMap: await sourceStore.transformCoverage(map),
sourceFinder: sourceStore.sourceFinder,
defaultSummarizer: 'nested',
watermarks: {
branches: [80, 100],
functions: [80, 100],
lines: [80, 100],
statements: [80, 100],
},
})
IstanbulReports.create('text').execute(reportContext)
})
cli.onClose(() => env.server.close())
await cli.open()