@exodus/test 1.0.0-rc.55 → 1.0.0-rc.57

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/test",
3
- "version": "1.0.0-rc.55",
3
+ "version": "1.0.0-rc.57",
4
4
  "author": "Exodus Movement, Inc.",
5
5
  "description": "A test suite runner",
6
6
  "homepage": "https://github.com/ExodusMovement/test",
package/src/dark.cjs CHANGED
@@ -108,7 +108,8 @@ 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.endsWith('node_modules/tsx/dist/loader.mjs'))
111
+ const esbuildLoaders = ['node_modules/tsx/dist/loader.mjs', '/loaders/esbuild.js']
112
+ const insideEsbuild = execArgv.some((x) => esbuildLoaders.some((y) => x.endsWith(y)))
112
113
 
113
114
  function makeEsbuildMockable() {
114
115
  if (!insideEsbuild) return
@@ -101,29 +101,28 @@ export async function installJestEnvironment(jestGlobals) {
101
101
  if (c.restoreMocks) beforeEach(() => jest.restoreAllMocks())
102
102
  if (c.resetModules) beforeEach(() => jest.resetModules())
103
103
 
104
- let require
104
+ let dynamicImport
105
105
  if (process.env.EXODUS_TEST_ENVIRONMENT === 'bundle') {
106
106
  const preloaded = new Map(EXODUS_TEST_PRELOADED) // eslint-disable-line no-undef
107
- require = (name) => {
107
+ dynamicImport = async (name) => {
108
108
  if (preloaded.has(name)) return preloaded.get(name)()
109
109
  assert.fail('Requiring non-bundled plugins from bundle is unsupported')
110
110
  }
111
111
  } else if (config.rootDir) {
112
112
  const { resolve } = await import('node:path')
113
- const { createRequire } = await import('node:module')
114
- require = createRequire(resolve(config.rootDir, 'package.json'))
113
+ dynamicImport = (path) => import(resolve(config.rootDir, path))
115
114
  } else {
116
- require = () => assert.fail('Unreachable: requiring plugins without a rootDir')
115
+ dynamicImport = async () => assert.fail('Unreachable: importing plugins without a rootDir')
117
116
  }
118
117
 
119
- for (const file of c.setupFiles || []) require(file)
118
+ for (const file of c.setupFiles || []) await dynamicImport(file)
120
119
 
121
120
  if (Object.hasOwn(specialEnvironments, c.testEnvironment)) {
122
121
  const { setup } = specialEnvironments[c.testEnvironment]
123
- await setup(require, engine, jestGlobals, c.testEnvironmentOptions)
122
+ await setup(dynamicImport, engine, jestGlobals, c.testEnvironmentOptions)
124
123
  }
125
124
 
126
- for (const file of c.setupFilesAfterEnv || []) require(file)
125
+ for (const file of c.setupFilesAfterEnv || []) await dynamicImport(file)
127
126
 
128
127
  // @jest/globals import auto-mocking is disabled until https://github.com/nodejs/node/issues/53807 is resolved
129
128
  /*
@@ -3,8 +3,8 @@ export const specialEnvironments = {
3
3
 
4
4
  jsdom: {
5
5
  dependencies: ['jsdom'],
6
- setup: (require) => {
7
- const { JSDOM, VirtualConsole } = require('jsdom')
6
+ setup: async (dynamicImport) => {
7
+ const { JSDOM, VirtualConsole } = await dynamicImport('jsdom')
8
8
  const virtualConsole = new VirtualConsole()
9
9
  const dom = new JSDOM('<!DOCTYPE html>', {
10
10
  url: 'http://localhost/',
package/src/jest.js CHANGED
@@ -51,7 +51,7 @@ const eachCallerLocation = []
51
51
  const makeEach =
52
52
  (impl) =>
53
53
  (list, ...rest) =>
54
- (template, fn) => {
54
+ (template, fn, ...restArgs) => {
55
55
  eachCallerLocation.unshift(getCallerLocation())
56
56
  // Hack for common testing with simple arrow functions, until we can disable esbuild minification
57
57
  const formatArg = (x) => (x && x instanceof Function && `${x}` === '()=>{}' ? '() => {}' : x)
@@ -86,7 +86,7 @@ const makeEach =
86
86
  if (length > 0) name = utilFormat(name, ...args.slice(0, length).map(formatArg))
87
87
  }
88
88
 
89
- impl(name, () => (Array.isArray(args) ? fn(...args) : fn(args)))
89
+ impl(name, () => (Array.isArray(args) ? fn(...args) : fn(args)), ...restArgs)
90
90
  }
91
91
 
92
92
  eachCallerLocation.shift()