@exodus/test 1.0.0-rc.26 → 1.0.0-rc.27
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 +7 -8
- package/package.json +2 -2
- package/src/dark.cjs +1 -1
- package/src/engine.pure.cjs +7 -2
- package/src/jest.js +1 -1
- package/src/jest.mock.js +3 -1
package/bin/index.js
CHANGED
|
@@ -37,10 +37,6 @@ function parseOptions() {
|
|
|
37
37
|
debug: { files: false },
|
|
38
38
|
ideaCompat: false,
|
|
39
39
|
engine: process.env.EXODUS_TEST_ENGINE ?? 'node:test',
|
|
40
|
-
// Engine options
|
|
41
|
-
binary: 'node',
|
|
42
|
-
pure: false,
|
|
43
|
-
hasImportLoader: false,
|
|
44
40
|
}
|
|
45
41
|
|
|
46
42
|
const args = [...process.argv]
|
|
@@ -233,8 +229,11 @@ if (options.esbuild) {
|
|
|
233
229
|
assert(resolveImport)
|
|
234
230
|
if (options.hasImportLoader) {
|
|
235
231
|
args.push('--import', resolveImport('tsx'))
|
|
232
|
+
} else if (options.engine === process.env.EXODUS_TEST_ENGINE) {
|
|
233
|
+
console.warn(`Warning: ${options.engine} engine does not support --esbuild option`)
|
|
236
234
|
} else {
|
|
237
|
-
|
|
235
|
+
console.error(`Error: ${options.engine} engine does not support --esbuild option`)
|
|
236
|
+
process.exit(1)
|
|
238
237
|
}
|
|
239
238
|
}
|
|
240
239
|
|
|
@@ -350,9 +349,9 @@ if (options.pure) {
|
|
|
350
349
|
console.log(`All ${files.length} test suites passed`)
|
|
351
350
|
}
|
|
352
351
|
} else {
|
|
353
|
-
assert(['node', c8].includes(options.binary),
|
|
354
|
-
assert
|
|
355
|
-
process.env.EXODUS_TEST_CONTEXT =
|
|
352
|
+
assert(['node', c8].includes(options.binary), `Unexpected native engine: ${options.binary}`)
|
|
353
|
+
assert(['node:test'].includes(options.engine))
|
|
354
|
+
process.env.EXODUS_TEST_CONTEXT = options.engine
|
|
356
355
|
const node = spawn(options.binary, [...args, ...files], { stdio: 'inherit' })
|
|
357
356
|
const [code] = await once(node, 'close')
|
|
358
357
|
process.exitCode = code
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/test",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.27",
|
|
4
4
|
"author": "Exodus Movement, Inc.",
|
|
5
5
|
"description": "A test suite runner",
|
|
6
6
|
"homepage": "https://github.com/ExodusMovement/test",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test": "npm run test:jest",
|
|
61
61
|
"test:all": "npm run test:jest && npm run test:tape && npm run test:native",
|
|
62
|
-
"test:native": "EXODUS_TEST_IGNORE='{**/typescript/**,**/jest-repo/**/user.test.js}' ./bin/index.js --jest '__test__/**/*.test.js'",
|
|
62
|
+
"test:native": "EXODUS_TEST_IGNORE='{**/typescript/**,**/jest-repo/**/user.test.js}' ./bin/index.js --jest '__test__/**/*.test.{js,cjs,mjs}'",
|
|
63
63
|
"test:jest": "./bin/index.js --jest --esbuild",
|
|
64
64
|
"test:tape": "./bin/index.js --esbuild '__test__/tape/test/*.js' __test__/tape.test.js",
|
|
65
65
|
"test:pure": "EXODUS_TEST_ENGINE=node:pure npm run test",
|
package/src/dark.cjs
CHANGED
|
@@ -108,7 +108,7 @@ function getTestNamePath(t) {
|
|
|
108
108
|
const execArgv = process.env.EXODUS_TEST_EXECARGV
|
|
109
109
|
? JSON.parse(process.env.EXODUS_TEST_EXECARGV)
|
|
110
110
|
: process.execArgv
|
|
111
|
-
const insideEsbuild = execArgv.some((x) => x.
|
|
111
|
+
const insideEsbuild = execArgv.some((x) => x.endsWith('node_modules/tsx/dist/loader.mjs'))
|
|
112
112
|
|
|
113
113
|
function makeEsbuildMockable() {
|
|
114
114
|
if (!insideEsbuild) return
|
package/src/engine.pure.cjs
CHANGED
|
@@ -3,7 +3,12 @@ const assertLoose = require('node:assert')
|
|
|
3
3
|
const { existsSync, readFileSync } = require('node:fs')
|
|
4
4
|
const { normalize, basename, dirname, join: pathJoin } = require('node:path')
|
|
5
5
|
const { format: utilFormat } = require('node:util')
|
|
6
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
createRequire,
|
|
8
|
+
builtinModules,
|
|
9
|
+
syncBuiltinESMExports,
|
|
10
|
+
syncBuiltinExports, // bun has it under a different name (also a no-op and always synced atm)
|
|
11
|
+
} = require('node:module')
|
|
7
12
|
|
|
8
13
|
const { setTimeout, setInterval, setImmediate, Date } = globalThis
|
|
9
14
|
const { clearTimeout, clearInterval, clearImmediate } = globalThis
|
|
@@ -329,7 +334,7 @@ module.exports = {
|
|
|
329
334
|
engine: 'pure',
|
|
330
335
|
...{ assert, assertLoose },
|
|
331
336
|
...{ mock, describe, test, beforeEach, afterEach, before, after },
|
|
332
|
-
...{ builtinModules, syncBuiltinESMExports },
|
|
337
|
+
...{ builtinModules, syncBuiltinESMExports: syncBuiltinESMExports || syncBuiltinExports },
|
|
333
338
|
...{ utilFormat, isPromise, nodeVersion },
|
|
334
339
|
...{ baseFile, relativeRequire, isTopLevelESM },
|
|
335
340
|
...{ readSnapshot, setSnapshotSerializers, setSnapshotResolver },
|
package/src/jest.js
CHANGED
|
@@ -178,7 +178,7 @@ export const jest = {
|
|
|
178
178
|
engine: String(node.engine),
|
|
179
179
|
timers: Boolean(mock.timers && haveValidTimers),
|
|
180
180
|
esmMocks: Boolean(mock.module), // full support for ESM mocks
|
|
181
|
-
|
|
181
|
+
esmInterop: Boolean(insideEsbuild), // loading/using ESM as CJS, ESM mocks creation without a mocker function
|
|
182
182
|
esmNamedBuiltinMocks: Boolean(mock.module || insideEsbuild), // support for named ESM imports from builtin module mocks
|
|
183
183
|
concurrency: node.engine !== 'pure', // pure engine doesn't support concurrency
|
|
184
184
|
},
|
package/src/jest.mock.js
CHANGED
|
@@ -132,7 +132,9 @@ function mockCloneItem(obj, cache) {
|
|
|
132
132
|
// Special path, as .default might be a getter and we want to unwrap it
|
|
133
133
|
if (obj.__esModule === true) {
|
|
134
134
|
const { __esModule, default: def, ...rest } = obj
|
|
135
|
-
|
|
135
|
+
const proto = Object.getPrototypeOf(obj)
|
|
136
|
+
const toClone = proto?.[Symbol.toStringTag] === 'Module' ? proto : { default: def, ...rest } // unwrap bun modules for proper cloning
|
|
137
|
+
return { __esModule, ...mockClone(toClone, cache) }
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
const prototype = Object.getPrototypeOf(obj)
|