Skip to content

Commit 6547f8e

Browse files
committed
feat: change createJestRunner argument
1 parent 0e88b6e commit 6547f8e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/@vuepress/test-utils/lib/createJestRunner.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ const usedPorts = []
66
* Run jest
77
*
88
* @param {array} jestArgs an array of Jest CLI options
9-
* @param {array} rawArgs the processed process.argv - contains '--inspect-brk' for debug
9+
* @param {array} debug whether start with '--inspect-brk' or not
1010
*/
1111

12-
module.exports = function createJestRunner (jestArgs, rawArgs) {
12+
module.exports = function createJestRunner (jestArgs, debug) {
1313
return async function () {
1414
const execArgv = getChildProcessExecArgv()
15-
const args = [...execArgv, ...jestArgs]
15+
const args = [require.resolve('jest-cli/bin/jest'), ...execArgv, ...jestArgs]
16+
if (debug) args.unshift('--inspect-brk')
1617
console.log(`running node with args: ${args.join(' ')}`)
17-
args.unshift(...rawArgs, require.resolve('jest-cli/bin/jest'))
1818
await execa('node', args, {
1919
stdio: 'inherit'
2020
})

scripts/test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const rawArgs = process.argv.slice(2)
66
const args = minimist(rawArgs)
77

88
let regex
9+
const debug = !!args['inspect-brk']
10+
911
if (args.p) {
1012
const packages = (args.p || args.package).split(',').join('|')
1113
regex = `.*@vuepress/(${packages}|plugin-(${packages}))/.*\\.spec\\.(js|ts)$`
@@ -17,7 +19,7 @@ const jestRunner = createJestRunner([
1719
'--config', 'scripts/jest.config.js',
1820
'--runInBand',
1921
...(regex ? [regex] : [])
20-
], rawArgs)
22+
], debug)
2123

2224
// ensure the basic temp files were generated
2325
createApp({

0 commit comments

Comments
 (0)