-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
71 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import engine from './engine.select.cjs' // need to be sync for non-preloaded imports into cjs | ||
|
||
const { assert, assertLoose } = engine | ||
export { assert, assertLoose } | ||
|
||
const { mock, describe, test, beforeEach, afterEach, before, after } = engine | ||
export { mock, describe, test, beforeEach, afterEach, before, after } | ||
|
||
const { builtinModules, syncBuiltinESMExports } = engine | ||
export { builtinModules, syncBuiltinESMExports } | ||
|
||
const { utilFormat, isPromise, nodeVersion } = engine | ||
export { utilFormat, isPromise, nodeVersion } | ||
|
||
const { baseFile, relativeRequire, isTopLevelESM } = engine | ||
export { baseFile, relativeRequire, isTopLevelESM } | ||
|
||
const { snapshot, readSnapshot, setSnapshotSerializers, setSnapshotResolver } = engine | ||
export { snapshot, readSnapshot, setSnapshotSerializers, setSnapshotResolver } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const assert = require('node:assert/strict') | ||
const assertLoose = require('node:assert') | ||
const { types, format: utilFormat } = require('node:util') | ||
const { existsSync, readFileSync } = require('node:fs') | ||
const { normalize, basename, dirname, join: pathJoin } = require('node:path') | ||
const { createRequire, builtinModules, syncBuiltinESMExports } = require('node:module') | ||
const nodeTest = require('node:test') | ||
|
||
const { mock, describe, test, beforeEach, afterEach, before, after } = nodeTest | ||
|
||
const isPromise = types.isPromise | ||
const nodeVersion = process.versions.node | ||
|
||
const files = process.argv.slice(1) | ||
const baseFile = files.length === 1 && existsSync(files[0]) ? normalize(files[0]) : undefined | ||
|
||
const relativeRequire = baseFile ? createRequire(baseFile) : require | ||
const isTopLevelESM = () => !baseFile || !Object.hasOwn(relativeRequire.cache, baseFile) // assume ESM otherwise | ||
|
||
const snapshot = nodeTest.snapshot | ||
let snapshotResolver = (dir, name) => [dir, `${name}.snapshot`] // default per Node.js docs | ||
const resolveSnapshot = (f) => pathJoin(...snapshotResolver(dirname(f), basename(f))) | ||
const readSnapshot = (f = baseFile) => (f ? readFileSync(resolveSnapshot(f), 'utf8') : null) | ||
const setSnapshotSerializers = (list) => snapshot?.setDefaultSnapshotSerializers(list) | ||
const setSnapshotResolver = (fn) => { | ||
snapshotResolver = fn | ||
snapshot?.setResolveSnapshotPath(resolveSnapshot) | ||
} | ||
|
||
/* eslint-disable unicorn/no-useless-spread */ | ||
module.exports = { | ||
...{ assert, assertLoose }, | ||
...{ mock, describe, test, beforeEach, afterEach, before, after }, | ||
...{ builtinModules, syncBuiltinESMExports }, | ||
...{ utilFormat, isPromise, nodeVersion }, | ||
...{ baseFile, relativeRequire, isTopLevelESM }, | ||
...{ snapshot, readSnapshot, setSnapshotSerializers, setSnapshotResolver }, | ||
} | ||
/* eslint-enable unicorn/no-useless-spread */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./engine.node.cjs') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters