@exodus/test 1.0.0-rc.42 → 1.0.0-rc.44
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/bundle.js +0 -16
- package/package.json +1 -1
- package/src/jest.environment.js +0 -47
- package/src/jest.js +4 -0
- package/src/jest.mock.js +2 -1
package/bin/bundle.js
CHANGED
|
@@ -28,8 +28,6 @@ const readSnapshots = async (files, resolvers) => {
|
|
|
28
28
|
return snapshots
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// These packages throw on import
|
|
32
|
-
const blockedDeps = ['@pollyjs/adapter-node-http', '@pollyjs/node-server']
|
|
33
31
|
const loadPipeline = [
|
|
34
32
|
function (source, filepath) {
|
|
35
33
|
return source
|
|
@@ -37,18 +35,6 @@ const loadPipeline = [
|
|
|
37
35
|
.replace(/\b(__dirname|import\.meta\.dirname)\b/g, JSON.stringify(dirname(filepath)))
|
|
38
36
|
.replace(/\b(__filename|import\.meta\.filename)\b/g, JSON.stringify(filepath))
|
|
39
37
|
},
|
|
40
|
-
function (source, filepath) {
|
|
41
|
-
// Just a convenience wrapper to show pretty errors instead of generic bundle-apis/empty/module-throw.cjs
|
|
42
|
-
for (const pkg of blockedDeps) {
|
|
43
|
-
const str = `require(${JSON.stringify(pkg)})`
|
|
44
|
-
assert(!str.includes("'"))
|
|
45
|
-
const err = `module unsupported in bundled form: ${pkg}\n loaded from ${filepath}`
|
|
46
|
-
const rep = `((() => { throw new Error(${JSON.stringify(err)}) })())`
|
|
47
|
-
for (const sub of [str, str.replaceAll('"', "'")]) source = source.replace(sub, rep)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return source
|
|
51
|
-
},
|
|
52
38
|
]
|
|
53
39
|
|
|
54
40
|
const options = {}
|
|
@@ -256,8 +242,6 @@ export const build = async (...files) => {
|
|
|
256
242
|
bindings: api('empty/function-throw.cjs'),
|
|
257
243
|
'node-gyp-build': api('empty/function-throw.cjs'),
|
|
258
244
|
ws: api('ws.cjs'),
|
|
259
|
-
// unsupported deps
|
|
260
|
-
...Object.fromEntries(blockedDeps.map((n) => [n, api('empty/module-throw.cjs')])),
|
|
261
245
|
},
|
|
262
246
|
sourcemap: ['hermes', 'jsc', 'd8'].includes(options.platform) ? 'inline' : 'linked', // FIXME?
|
|
263
247
|
sourcesContent: false,
|
package/package.json
CHANGED
package/src/jest.environment.js
CHANGED
|
@@ -30,51 +30,4 @@ export const specialEnvironments = {
|
|
|
30
30
|
} catch {}
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
|
-
|
|
34
|
-
// Reproduces setup-polly-jest/jest-environment-node and hacks into 'setup-polly-jest'.pollyJest
|
|
35
|
-
'setup-polly-jest/jest-environment-node': {
|
|
36
|
-
dependencies: ['@pollyjs/core', 'setup-polly-jest', 'setup-polly-jest/lib/common'],
|
|
37
|
-
setup: async (require, engine) => {
|
|
38
|
-
const { getTestNamePath } = await import('./dark.cjs')
|
|
39
|
-
// polly has bad defer impl in case if it finds MessageChannel but not process.* (e.g. on deno), forever blocking
|
|
40
|
-
const { MessageChannel } = globalThis
|
|
41
|
-
if (MessageChannel) globalThis.MessageChannel = undefined
|
|
42
|
-
const { Polly } = require('@pollyjs/core')
|
|
43
|
-
const pollyJest = require('setup-polly-jest')
|
|
44
|
-
const {
|
|
45
|
-
JestPollyGlobals,
|
|
46
|
-
createPollyContextAccessor,
|
|
47
|
-
} = require('setup-polly-jest/lib/common')
|
|
48
|
-
if (MessageChannel) globalThis.MessageChannel = MessageChannel
|
|
49
|
-
const pollyGlobals = new JestPollyGlobals(globalThis)
|
|
50
|
-
pollyGlobals.isJestPollyEnvironment = true
|
|
51
|
-
pollyJest.setupPolly = (options) => {
|
|
52
|
-
if (!pollyGlobals.isJestPollyEnvironment) return
|
|
53
|
-
|
|
54
|
-
engine.before(() => {
|
|
55
|
-
pollyGlobals.isPollyActive = true
|
|
56
|
-
pollyGlobals.pollyContext.options = options
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
engine.after(() => {
|
|
60
|
-
pollyGlobals.isPollyActive = false
|
|
61
|
-
pollyGlobals.pollyContext.options = null
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
return createPollyContextAccessor(pollyGlobals)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
engine.beforeEach((t) => {
|
|
68
|
-
if (!pollyGlobals.isPollyActive) return
|
|
69
|
-
const name = getTestNamePath(t).join('/')
|
|
70
|
-
pollyGlobals.pollyContext.polly = new Polly(name, pollyGlobals.pollyContext.options)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
engine.afterEach(async () => {
|
|
74
|
-
if (!pollyGlobals.pollyContext.polly) return
|
|
75
|
-
await pollyGlobals.pollyContext.polly.stop()
|
|
76
|
-
pollyGlobals.pollyContext.polly = null
|
|
77
|
-
})
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
33
|
}
|
package/src/jest.js
CHANGED
package/src/jest.mock.js
CHANGED
|
@@ -199,7 +199,8 @@ export function jestmock(name, mocker, { override = false } = {}) {
|
|
|
199
199
|
assert(mocker, 'Can not auto-clone a native ESM module without --esbuild or newer Node.js')
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
const
|
|
202
|
+
const expand = (obj) => (isObject(obj) ? { ...obj } : obj)
|
|
203
|
+
const value = mocker ? expand(mocker()) : mockClone(mapActual.get(resolved))
|
|
203
204
|
mapMocks.set(resolved, value)
|
|
204
205
|
|
|
205
206
|
let likelyESM = false
|