diff --git a/packages/@vuepress/test-utils/lib/createJestRunner.js b/packages/@vuepress/test-utils/lib/createJestRunner.js index eedc38c89f..56f57e8e8e 100644 --- a/packages/@vuepress/test-utils/lib/createJestRunner.js +++ b/packages/@vuepress/test-utils/lib/createJestRunner.js @@ -6,15 +6,15 @@ const usedPorts = [] * Run jest * * @param {array} jestArgs an array of Jest CLI options - * @param {array} rawArgs the processed process.argv - contains '--inspect-brk' for debug + * @param {array} debug whether start with '--inspect-brk' or not */ -module.exports = function createJestRunner (jestArgs, rawArgs) { +module.exports = function createJestRunner (jestArgs, debug) { return async function () { const execArgv = getChildProcessExecArgv() - const args = [...execArgv, ...jestArgs] + const args = [require.resolve('jest-cli/bin/jest'), ...execArgv, ...jestArgs] + if (debug) args.unshift('--inspect-brk') console.log(`running node with args: ${args.join(' ')}`) - args.unshift(...rawArgs, require.resolve('jest-cli/bin/jest')) await execa('node', args, { stdio: 'inherit' }) diff --git a/scripts/test.js b/scripts/test.js index 8e4c10cef1..686ba37e64 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -6,6 +6,8 @@ const rawArgs = process.argv.slice(2) const args = minimist(rawArgs) let regex +const debug = !!args['inspect-brk'] + if (args.p) { const packages = (args.p || args.package).split(',').join('|') regex = `.*@vuepress/(${packages}|plugin-(${packages}))/.*\\.spec\\.(js|ts)$` @@ -17,7 +19,7 @@ const jestRunner = createJestRunner([ '--config', 'scripts/jest.config.js', '--runInBand', ...(regex ? [regex] : []) -], rawArgs) +], debug) // ensure the basic temp files were generated createApp({