@exodus/test 1.0.0-rc.40 → 1.0.0-rc.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +15 -1
- package/package.json +1 -1
- package/src/jest.environment.js +11 -7
package/bin/index.js
CHANGED
|
@@ -54,6 +54,7 @@ function parseOptions() {
|
|
|
54
54
|
ideaCompat: false,
|
|
55
55
|
engine: process.env.EXODUS_TEST_ENGINE ?? 'node:test',
|
|
56
56
|
require: [],
|
|
57
|
+
testNamePattern: [],
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
const args = [...process.argv]
|
|
@@ -69,16 +70,22 @@ function parseOptions() {
|
|
|
69
70
|
|
|
70
71
|
while (args[0]?.startsWith('-')) {
|
|
71
72
|
const option = args.shift()
|
|
73
|
+
if (option.includes('=')) {
|
|
74
|
+
const [optionName, ...rest] = option.split('=')
|
|
75
|
+
args.unshift(optionName, rest.join('='))
|
|
76
|
+
continue
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
if (options.ideaCompat) {
|
|
73
80
|
// Ignore some options IntelliJ IDEA is passing
|
|
74
81
|
switch (option) {
|
|
75
82
|
case '--reporters':
|
|
83
|
+
case '--testTimeout':
|
|
76
84
|
args.shift()
|
|
77
85
|
continue
|
|
78
86
|
case '--verbose':
|
|
79
87
|
case '--runTestsByPath':
|
|
80
88
|
case '--runInBand':
|
|
81
|
-
case '--testTimeout=7200000':
|
|
82
89
|
continue
|
|
83
90
|
}
|
|
84
91
|
}
|
|
@@ -147,6 +154,10 @@ function parseOptions() {
|
|
|
147
154
|
case '--idea-compat':
|
|
148
155
|
options.ideaCompat = true
|
|
149
156
|
break
|
|
157
|
+
case '--test-name-pattern':
|
|
158
|
+
case '--testNamePattern':
|
|
159
|
+
options.testNamePattern.push(args.shift())
|
|
160
|
+
break
|
|
150
161
|
default:
|
|
151
162
|
throw new Error(`Unknown option: ${option}`)
|
|
152
163
|
}
|
|
@@ -185,6 +196,7 @@ if (options.pure) {
|
|
|
185
196
|
assert(!options.writeSnapshots, `Can not use write snapshots with ${options.engine} engine`)
|
|
186
197
|
assert(!options.forceExit, `Can not use --force-exit with ${options.engine} engine yet`) // TODO
|
|
187
198
|
assert(!options.watch, `Can not use --watch with with ${options.engine} engine`)
|
|
199
|
+
assert(options.testNamePattern.length === 0, '--test-name-pattern requires node:test engine now')
|
|
188
200
|
} else if (options.engine === 'node:test') {
|
|
189
201
|
args.push('--test', '--no-warnings=ExperimentalWarning', '--test-reporter=spec')
|
|
190
202
|
|
|
@@ -204,6 +216,8 @@ if (options.pure) {
|
|
|
204
216
|
if (options.watch) args.push('--watch')
|
|
205
217
|
if (options.only) args.push('--test-only')
|
|
206
218
|
|
|
219
|
+
for (const pattern of options.testNamePattern) args.push('--test-name-pattern', pattern)
|
|
220
|
+
|
|
207
221
|
args.push('--expose-internals') // this is unoptimal and hopefully temporary, see rationale in src/dark.cjs
|
|
208
222
|
} else {
|
|
209
223
|
throw new Error('Unreachable')
|
package/package.json
CHANGED
package/src/jest.environment.js
CHANGED
|
@@ -6,7 +6,7 @@ export const specialEnvironments = {
|
|
|
6
6
|
setup: (require) => {
|
|
7
7
|
const { JSDOM, VirtualConsole } = require('jsdom')
|
|
8
8
|
const virtualConsole = new VirtualConsole()
|
|
9
|
-
const
|
|
9
|
+
const dom = new JSDOM('<!DOCTYPE html>', {
|
|
10
10
|
url: 'http://localhost/',
|
|
11
11
|
pretendToBeVisual: true,
|
|
12
12
|
runScripts: 'dangerously',
|
|
@@ -17,17 +17,21 @@ export const specialEnvironments = {
|
|
|
17
17
|
throw error
|
|
18
18
|
})
|
|
19
19
|
const assignMissing = (target, source) => {
|
|
20
|
-
const
|
|
21
|
-
Object.
|
|
20
|
+
const descriptors = Object.getOwnPropertyDescriptors(source)
|
|
21
|
+
const entries = Object.entries(descriptors).filter(([key]) => !Object.hasOwn(target, key))
|
|
22
|
+
Object.defineProperties(target, Object.fromEntries(entries))
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
assignMissing(globalThis, window)
|
|
25
|
-
assignMissing(console, window.console)
|
|
26
|
-
Object.setPrototypeOf(
|
|
25
|
+
assignMissing(globalThis, dom.window)
|
|
26
|
+
assignMissing(console, dom.window.console)
|
|
27
|
+
Object.setPrototypeOf(globalThis, Object.getPrototypeOf(dom.window))
|
|
28
|
+
try {
|
|
29
|
+
assignMissing(globalThis, dom.getInternalVMContext())
|
|
30
|
+
} catch {}
|
|
27
31
|
},
|
|
28
32
|
},
|
|
29
33
|
|
|
30
|
-
// Reproduces setup-polly-jest/jest-environment-node
|
|
34
|
+
// Reproduces setup-polly-jest/jest-environment-node and hacks into 'setup-polly-jest'.pollyJest
|
|
31
35
|
'setup-polly-jest/jest-environment-node': {
|
|
32
36
|
dependencies: ['@pollyjs/core', 'setup-polly-jest', 'setup-polly-jest/lib/common'],
|
|
33
37
|
setup: async (require, engine) => {
|