Skip to content

Commit ca7dc9b

Browse files
committed
feat: --devtools support on node:test
1 parent 2a7c463 commit ca7dc9b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

bin/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ if (!process.env.FORCE_COLOR && process.stdout.hasColors?.() && process.stderr.h
256256
}
257257

258258
const engineName = `${options.engine} engine` // used for warnings to user
259+
const engineFlagError = (flag) => `${engineName} does not support --${flag}`
259260
const engineOptions = ENGINES.get(options.engine)
260261
assert(engineOptions, `Unknown engine: ${options.engine}`)
261262
Object.assign(options, engineOptions)
@@ -269,8 +270,8 @@ setEnv('EXODUS_TEST_IS_BROWSER', isBrowserLike ? '1' : '')
269270
setEnv('EXODUS_TEST_IS_BAREBONE', options.barebone ? '1' : '')
270271
setEnv('EXODUS_TEST_ENVIRONMENT', options.bundle ? 'bundle' : '') // perhaps switch to _IS_BUNDLED?
271272

272-
assert(!options.devtools || isBrowserLike, '--devtools can be only used with browser engines')
273-
assert(!options.throttle || options.browsers, `${engineName} does not support --throttle-cpu`)
273+
assert(!options.devtools || isBrowserLike || !options.pure, engineFlagError('devtools'))
274+
assert(!options.throttle || options.browsers, engineFlagError('throttle-cpu'))
274275

275276
const require = createRequire(import.meta.url)
276277
const resolveRequire = (query) => require.resolve(query)
@@ -690,6 +691,11 @@ if (options.pure) {
690691
assert(files.length > 0) // otherwise we can run recursively
691692
assert(!options.binaryArgs)
692693
if (options.concurrency) args.push('--test-concurrency', options.concurrency)
694+
if (options.devtools) {
695+
args.push('--inspect-brk')
696+
console.warn('Open chrome://inspect/ for connecting devtools')
697+
}
698+
693699
const { code } = await launch(options.binary, [...args, ...files])
694700
process.exitCode = code
695701
}

0 commit comments

Comments
 (0)