@exodus/test 1.0.0-rc.7 → 1.0.0-rc.70
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/LICENSE +21 -0
- package/README.md +121 -45
- package/bin/browsers.js +97 -0
- package/bin/find-binary.js +67 -0
- package/bin/inband.js +11 -0
- package/bin/index.js +486 -72
- package/bin/jest.js +4 -10
- package/bin/reporter.js +202 -0
- package/bundler/babel-worker.cjs +62 -0
- package/bundler/bundle.js +391 -0
- package/bundler/modules/ansi-styles.cjs +49 -0
- package/bundler/modules/assert-strict.cjs +1 -0
- package/bundler/modules/child_process.cjs +10 -0
- package/bundler/modules/cluster.cjs +27 -0
- package/bundler/modules/crypto.cjs +5 -0
- package/bundler/modules/empty/function-throw.cjs +4 -0
- package/bundler/modules/empty/module-throw.cjs +1 -0
- package/bundler/modules/fs-promises.cjs +1 -0
- package/bundler/modules/fs.cjs +123 -0
- package/bundler/modules/globals.cjs +233 -0
- package/bundler/modules/http.cjs +119 -0
- package/bundler/modules/https.cjs +11 -0
- package/bundler/modules/jest-message-util.js +5 -0
- package/bundler/modules/jest-util.js +22 -0
- package/bundler/modules/node-buffer.cjs +3 -0
- package/bundler/modules/text-encoding-utf.cjs +90 -0
- package/bundler/modules/tty.cjs +10 -0
- package/bundler/modules/url.cjs +32 -0
- package/bundler/modules/util-format.cjs +48 -0
- package/bundler/modules/ws.cjs +20 -0
- package/expect.cjs +1 -0
- package/jest.js +1 -0
- package/loaders/esbuild.js +1 -0
- package/loaders/typescript.js +3 -0
- package/loaders/typescript.loader.js +24 -0
- package/node.js +1 -0
- package/package.json +131 -12
- package/src/dark.cjs +146 -0
- package/src/engine.js +22 -0
- package/src/engine.node.cjs +41 -0
- package/src/engine.pure.cjs +540 -0
- package/src/engine.pure.snapshot.cjs +35 -0
- package/src/engine.select.cjs +5 -0
- package/src/expect.cjs +125 -0
- package/src/jest.config.fs.js +54 -0
- package/src/jest.config.js +138 -0
- package/src/jest.environment.js +33 -0
- package/src/jest.fn.js +19 -21
- package/src/jest.js +236 -48
- package/src/jest.mock.js +211 -60
- package/src/jest.snapshot.js +106 -38
- package/src/jest.timers.js +48 -14
- package/src/node.js +10 -0
- package/src/replay.js +103 -0
- package/src/tape.cjs +15 -0
- package/src/tape.js +33 -8
- package/src/version.js +18 -0
- package/tape.js +1 -0
- /package/{bin → loaders}/babel.cjs +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Exodus Movement, Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,52 +1,95 @@
|
|
|
1
1
|
# @exodus/test
|
|
2
2
|
|
|
3
|
-
A runner for `node:test`, `jest`, and `tape` test suites on top of `node:test`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
|
|
3
|
+
A runner for `node:test`, `jest`, and `tape` test suites on top of `node:test` (and any runtime)
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Native ESM, including in Jest tests
|
|
8
|
+
- Esbuild on the fly for babelified ESM interop (enable via `--esbuild`)
|
|
9
|
+
- TypeScript support in both transform (through [tsx](https://tsx.is/), enable via `--esbuild`)
|
|
10
|
+
and typestrip (via `--typescript`) modes
|
|
11
|
+
- Runs on [node:test](https://nodejs.org/api/test.html), and (experimental) on bun, deno, d8, JSC,
|
|
12
|
+
[Hermes](https://hermesengine.dev), Chrome, Firefox and WebKit.
|
|
13
|
+
- Testsuite-agnostic -- can run any file as long as it sets exit code based on test results
|
|
14
|
+
- Built-in [Jest](https://jestjs.io) compatibility (with `--jest`), including `jest.*` global
|
|
15
|
+
- Up to ~10x faster depending on the original setup
|
|
16
|
+
- Actual `expect` module, also `jest-extended` and `jest-when` just work on top
|
|
17
|
+
- Snapshots, including snapshot matchers
|
|
18
|
+
- Function and timer mocks
|
|
19
|
+
- [test.concurrent]()
|
|
20
|
+
- Module mocks (on top of Node.js runtime only), including for ESM modules
|
|
21
|
+
- Loads Jest configuration
|
|
22
|
+
- It works on Hermes too!
|
|
23
|
+
- Built-in network record/replay for offline tests, mocking `fetch` and `WebSocket` sessions
|
|
24
|
+
- `--drop-network` support for guaranteed offline testing
|
|
25
|
+
- Native code coverage via v8 (Node.js or [c8](https://github.com/bcoe/c8)), with istanbul reporters
|
|
26
|
+
- GitHub reporter (auto-enabled by default)
|
|
27
|
+
- JSDOM env support
|
|
28
|
+
- Hanging tests error by default (unlike `jest`)
|
|
29
|
+
- Babel support, picks up your Babel config (enable via `--babel`)
|
|
30
|
+
- Unlike `bun:test`, it runs test files in isolated contexts \
|
|
31
|
+
Bun leaks globals / side effects between test files ([ref](https://github.com/oven-sh/bun/issues/6024)),
|
|
32
|
+
and has incompatible `test()` lifecycle / order
|
|
33
|
+
- Also features a tape API for drop-in replacement
|
|
34
|
+
|
|
35
|
+
## Reporter samples
|
|
36
|
+
|
|
37
|
+
#### CLI (but uses colors when output supports them, e.g. in terminal):
|
|
38
|
+
|
|
39
|
+
```console
|
|
40
|
+
# tests/jest/expect.mock.test.js
|
|
41
|
+
✔ PASS drinkAll > drinks something lemon-flavoured (1.300417ms)
|
|
42
|
+
✔ PASS drinkAll > does not drink something octopus-flavoured (0.191791ms)
|
|
43
|
+
✔ PASS drinkAll (1.842959ms)
|
|
44
|
+
✔ PASS drinkEach > drinkEach drinks each drink (0.360625ms)
|
|
45
|
+
✔ PASS drinkEach (0.463416ms)
|
|
46
|
+
✔ PASS toHaveBeenCalledWith > registration applies correctly to orange La Croix (0.53325ms)
|
|
47
|
+
✔ PASS toHaveBeenCalledWith (0.564166ms)
|
|
48
|
+
✔ PASS toHaveBeenLastCalledWith > applying to all flavors does mango last (0.380375ms)
|
|
49
|
+
✔ PASS toHaveBeenLastCalledWith (0.473417ms)
|
|
50
|
+
# tests/jest/fn.invocationCallOrder.test.js
|
|
51
|
+
✔ PASS mock.invocationCallOrder (4.221042ms)
|
|
41
52
|
```
|
|
42
53
|
|
|
43
|
-
|
|
54
|
+
#### GitHub Actions collapses test results per-file, like this:
|
|
55
|
+
|
|
56
|
+
<details>
|
|
57
|
+
<summary>✅ <strong>tests/jest/lifecycle.test.js</strong></summary>
|
|
58
|
+
<pre>
|
|
59
|
+
✔ PASS A > B > C (3.26166ms)
|
|
60
|
+
✔ PASS A > B > D (1.699463ms)
|
|
61
|
+
✔ PASS A > B (6.72719ms)
|
|
62
|
+
✔ PASS A > E > F (1.117997ms)
|
|
63
|
+
✔ PASS A > E > G > H (1.330904ms)
|
|
64
|
+
✔ PASS A > E > G (1.94971ms)
|
|
65
|
+
✔ PASS A > E (3.821825ms)
|
|
66
|
+
✔ PASS A > I (0.533096ms)
|
|
67
|
+
✔ PASS A (13.887889ms)
|
|
68
|
+
✔ PASS J (0.373187ms)
|
|
69
|
+
✔ PASS K > L (0.659852ms)
|
|
70
|
+
✔ PASS K (1.143195ms)
|
|
71
|
+
</pre>
|
|
72
|
+
</details><details>
|
|
73
|
+
<summary>✅ <strong>tests/jest/timers.async.test.js</strong></summary>
|
|
74
|
+
<pre>
|
|
75
|
+
✔ PASS advanceTimersByTime() does not let microtasks to pass (5.326604ms)
|
|
76
|
+
✔ PASS advanceTimersByTime() does not let microtasks to pass even with await (1.336064ms)
|
|
77
|
+
✔ PASS advanceTimersByTimeAsync() lets microtasks to pass (6.99526ms)
|
|
78
|
+
✔ PASS advanceTimersByTimeAsync() lets microtasks to pass, chained (10.131664ms)
|
|
79
|
+
✔ PASS advanceTimersByTimeAsync() lets microtasks to pass, longer chained (8.635472ms)
|
|
80
|
+
✔ PASS advanceTimersByTimeAsync() lets microtasks to pass, async chain (56.937983ms)
|
|
81
|
+
</pre>
|
|
82
|
+
</details>
|
|
83
|
+
|
|
84
|
+
See live output in [CI](https://github.com/ExodusMovement/test/actions/workflows/checks.yaml)
|
|
44
85
|
|
|
45
|
-
|
|
86
|
+
## Library
|
|
46
87
|
|
|
47
88
|
### List of exports
|
|
48
89
|
|
|
49
|
-
- `@exodus/test/
|
|
90
|
+
- `@exodus/test/node` -- `node:test` API, working under non-Node.js platforms
|
|
91
|
+
|
|
92
|
+
- `@exodus/test/jest` -- `jest` implementation
|
|
50
93
|
|
|
51
94
|
- `@exodus/test/tape` -- `tape` mock (can also be helpful when moving from `tap`)
|
|
52
95
|
|
|
@@ -56,11 +99,9 @@ Just use `"test": "exodus-test"`
|
|
|
56
99
|
|
|
57
100
|
### Options
|
|
58
101
|
|
|
59
|
-
- `--jest` -- register jest test helpers as global variables
|
|
102
|
+
- `--jest` -- register jest test helpers as global variables, also load `jest.config.*` configuration options
|
|
60
103
|
|
|
61
|
-
- `--
|
|
62
|
-
|
|
63
|
-
- `--esbuild` -- use esbuild loader (currently an alias for `--typescript`)
|
|
104
|
+
- `--esbuild` -- use esbuild loader, also enables Typescript support
|
|
64
105
|
|
|
65
106
|
- `--babel` -- use babel loader (slower than `--esbuild`, makes sense if you have a special config)
|
|
66
107
|
|
|
@@ -72,8 +113,43 @@ Just use `"test": "exodus-test"`
|
|
|
72
113
|
|
|
73
114
|
- `--watch` -- operate in watch mode and re-run tests on file changes
|
|
74
115
|
|
|
116
|
+
- `--only` -- only run the tests marked with `test.only`
|
|
117
|
+
|
|
75
118
|
- `--passWithNoTests` -- do not error when no test files were found
|
|
76
119
|
|
|
77
120
|
- `--write-snapshots` -- write snapshots instead of verifying them (has `--test-update-snapshots` alias)
|
|
78
121
|
|
|
79
122
|
- `--test-force-exit` -- force exit after tests are done (useful in integration tests where it could be unfeasible to resolve all open handles)
|
|
123
|
+
|
|
124
|
+
## Jest compatibility
|
|
125
|
+
|
|
126
|
+
The `--jest` mode is mostly compatible with Jest. There are some noteworthy differences though.
|
|
127
|
+
This tool does not hoist mocks, so it is important that a mock is defined before the module that uses it is imported.
|
|
128
|
+
In ESM, this can be achieved with dynamic imports:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
jest.mock('./hogwarts.js', () => {
|
|
132
|
+
return {
|
|
133
|
+
__esModule: true,
|
|
134
|
+
default: jest.fn(),
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
const { default: getEntryQualification } = await import('./hogwarts.js')
|
|
139
|
+
const { qualifiesForHogwarts } = await import('./wizard.js') // module importing ./hogwarts.js
|
|
140
|
+
|
|
141
|
+
test('qualifies for Hogwarts', () => {
|
|
142
|
+
// doSomething is a mock function
|
|
143
|
+
getEntryQualification.mockReturnValue(['lumos'])
|
|
144
|
+
|
|
145
|
+
expect(qualifiesForHogwarts('potter')).toBe(false)
|
|
146
|
+
getEntryQualification.mockReturnValue([])
|
|
147
|
+
expect(qualifiesForHogwarts('potter')).toBe(true)
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Note that all modules that transitively import `hogwarts.js` will have to be imported after the mock is defined.
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
[MIT](./LICENSE)
|
package/bin/browsers.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import { readFile } from 'node:fs/promises'
|
|
3
|
+
import { findBinary } from './find-binary.js'
|
|
4
|
+
|
|
5
|
+
// See https://playwright.dev/docs/browsers
|
|
6
|
+
// > Playwright doesn't work with the branded version of Firefox since it relies on patches.
|
|
7
|
+
// > Playwright doesn't work with the branded version of Safari since it relies on patches.
|
|
8
|
+
// We don't even attempt to use built-in engine for Chromium, just rely on Playwright to load its.
|
|
9
|
+
// To run system browsers, we use Puppeteer.
|
|
10
|
+
|
|
11
|
+
let puppeteer
|
|
12
|
+
let playwright
|
|
13
|
+
|
|
14
|
+
const launched = Object.create(null)
|
|
15
|
+
const launchers = {
|
|
16
|
+
async puppeteer({ binary, devtools }) {
|
|
17
|
+
if (!puppeteer) puppeteer = await import('puppeteer-core')
|
|
18
|
+
assert(['chrome', 'firefox'].includes(binary))
|
|
19
|
+
return puppeteer.launch({ executablePath: findBinary(binary), browser: binary, devtools })
|
|
20
|
+
},
|
|
21
|
+
async playwright({ binary, devtools }) {
|
|
22
|
+
if (!playwright) playwright = await import('playwright-core')
|
|
23
|
+
assert(['chromium', 'firefox', 'webkit'].includes(binary) && Object.hasOwn(playwright, binary))
|
|
24
|
+
return playwright[binary].launch({ devtools })
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const close = () => Promise.all(Object.values(launched).map((p) => p.then((b) => b.close())))
|
|
29
|
+
|
|
30
|
+
async function newPage(runner, browser, { binary, dropNetwork }) {
|
|
31
|
+
const context = await (browser.newContext ? browser.newContext() : browser.createBrowserContext())
|
|
32
|
+
if (dropNetwork && context.setOffline && binary !== 'webkit') await context.setOffline(true) // WebKit crashes if this is done prior to navigation to /dev/null
|
|
33
|
+
let page
|
|
34
|
+
try {
|
|
35
|
+
page = await context.newPage()
|
|
36
|
+
} catch (err) {
|
|
37
|
+
// Puppeteer has a bug with Firefox, we expect that and just retry
|
|
38
|
+
if (runner !== 'puppeteer' || binary !== 'firefox' || err.name !== 'ProtocolError') throw err
|
|
39
|
+
await context.close()
|
|
40
|
+
return newPage(runner, browser, { binary, dropNetwork })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
await page.goto('file:///dev/null') // Need to load a secure origin for e.g. crypto.subtle to be available
|
|
44
|
+
|
|
45
|
+
if (dropNetwork && context.setOffline) await context.setOffline(true)
|
|
46
|
+
if (dropNetwork && page.setOfflineMode) await page.setOfflineMode(true)
|
|
47
|
+
assert(!dropNetwork || context.setOffline || page.setOfflineMode)
|
|
48
|
+
return { context, page }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function run(runner, args, { binary, devtools, dropNetwork, timeout }) {
|
|
52
|
+
assert(args.length === 1, 'Unexpected args to browser runner')
|
|
53
|
+
|
|
54
|
+
const bundle = await readFile(args[0], 'utf8')
|
|
55
|
+
let code = 0
|
|
56
|
+
const [stdout, stderr] = [[], []]
|
|
57
|
+
|
|
58
|
+
assert(Object.hasOwn(launchers, runner), 'Unexpected runner')
|
|
59
|
+
if (!launched[runner]) launched[runner] = launchers[runner]({ binary, devtools })
|
|
60
|
+
const { page, context } = await newPage(runner, await launched[runner], { binary, dropNetwork })
|
|
61
|
+
|
|
62
|
+
page.on('console', (message) => {
|
|
63
|
+
const type = message.type()
|
|
64
|
+
const target = type === 'error' ? stderr : stdout
|
|
65
|
+
target.push(message.text())
|
|
66
|
+
})
|
|
67
|
+
page.on('pageerror', (error) => {
|
|
68
|
+
if (!code) code = 1
|
|
69
|
+
stderr.push(`${error}`)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
let timer
|
|
73
|
+
const promise = new Promise((resolve) => {
|
|
74
|
+
timer = setTimeout(() => {
|
|
75
|
+
stderr.push('timeout reached')
|
|
76
|
+
resolve(1) // Error code
|
|
77
|
+
}, timeout)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
const wait = async () => {
|
|
81
|
+
await page.evaluate(bundle)
|
|
82
|
+
return page.evaluate('globalThis.EXODUS_TEST_PROMISE')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
// exitCode might be undefined if we failed before EXODUS_TEST_PROMISE was set, but we will have code then
|
|
87
|
+
const exitCode = await Promise.race([wait(), promise])
|
|
88
|
+
code = code || exitCode
|
|
89
|
+
assert(Number.isInteger(code))
|
|
90
|
+
return { code, stdout: stdout.join('\n'), stderr: stderr.join('\n') }
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return { code: 1, stdout: '', stderr: `${error}` }
|
|
93
|
+
} finally {
|
|
94
|
+
clearTimeout(timer)
|
|
95
|
+
await context.close()
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import { dirname, join } from 'node:path'
|
|
3
|
+
import { createRequire } from 'node:module'
|
|
4
|
+
|
|
5
|
+
const require = createRequire(import.meta.url)
|
|
6
|
+
|
|
7
|
+
// Can modify PATH to add the binary to it!
|
|
8
|
+
function findBinaryOnce(name) {
|
|
9
|
+
const paths = []
|
|
10
|
+
const addPaths = (platform, ...args) => process.platform === platform && paths.push(...args)
|
|
11
|
+
|
|
12
|
+
switch (name) {
|
|
13
|
+
case 'hermes':
|
|
14
|
+
try {
|
|
15
|
+
const dir = dirname(require.resolve('hermes-engine-cli/package.json'))
|
|
16
|
+
const platformDirs = { darwin: 'osx-bin', linux: 'linux64-bin', win32: 'win64-bin' }
|
|
17
|
+
if (Object.hasOwn(platformDirs, process.platform)) {
|
|
18
|
+
process.env.PATH = `${join(dir, platformDirs[process.platform])}:${process.env.PATH}`
|
|
19
|
+
} else {
|
|
20
|
+
console.error(`Unexpected platform: ${process.platform}`)
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
console.warn("'hermes-engine-cli' not installed, attempting to load global `hermes`...")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return 'hermes'
|
|
27
|
+
case 'jsc':
|
|
28
|
+
if (process.platform === 'darwin') {
|
|
29
|
+
const prefix = '/System/Library/Frameworks/JavaScriptCore.framework/Versions/A'
|
|
30
|
+
for (const dir of [`${prefix}/Helpers`, `${prefix}/Resources`]) {
|
|
31
|
+
if (existsSync(join(dir, 'jsc'))) {
|
|
32
|
+
process.env.PATH = `${dir}:${process.env.PATH}`
|
|
33
|
+
break
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return 'jsc'
|
|
39
|
+
case 'electron':
|
|
40
|
+
return require('electron')
|
|
41
|
+
case 'c8':
|
|
42
|
+
return require.resolve('c8/bin/c8.js')
|
|
43
|
+
case 'chrome':
|
|
44
|
+
addPaths('darwin', '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome')
|
|
45
|
+
addPaths('linux', '/usr/bin/chromium', '/snap/bin/chromium', '/usr/bin/google-chrome')
|
|
46
|
+
break
|
|
47
|
+
case 'firefox':
|
|
48
|
+
addPaths('darwin', '/Applications/Firefox.app/Contents/MacOS/firefox')
|
|
49
|
+
addPaths('linux', '/usr/bin/firefox')
|
|
50
|
+
break
|
|
51
|
+
case 'safari':
|
|
52
|
+
addPaths('darwin', '/Applications/Safari.app/Contents/MacOS/Safari')
|
|
53
|
+
break
|
|
54
|
+
default:
|
|
55
|
+
throw new Error('Trying to find an unexpected executable name')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
for (const path of paths) if (existsSync(path)) return path
|
|
59
|
+
throw new Error(`Failed to find ${name} executable`)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const binaries = new Map()
|
|
63
|
+
|
|
64
|
+
export function findBinary(name) {
|
|
65
|
+
if (!binaries.has(name)) binaries.set(name, findBinaryOnce(name))
|
|
66
|
+
return binaries.get(name)
|
|
67
|
+
}
|
package/bin/inband.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import { describe } from '../src/engine.js'
|
|
3
|
+
|
|
4
|
+
const files = JSON.parse(process.env.EXODUS_TEST_INBAND)
|
|
5
|
+
if (!Array.isArray(files)) throw new Error('Unexpected')
|
|
6
|
+
|
|
7
|
+
for (const file of files.sort()) {
|
|
8
|
+
await describe(`EXODUS_TEST_INBAND:${file}`, async () => {
|
|
9
|
+
await import(resolve(file))
|
|
10
|
+
})
|
|
11
|
+
}
|