Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fail to test specific package #2099

Merged
merged 3 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions packages/@vuepress/test-utils/lib/createJestRunner.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
const execa = require('execa')
const rawArgs = process.argv.slice(2)

const usedPorts = []

module.exports = function createJestRunner (jestArgs) {
/**
* Run jest
*
* @param {array} jestArgs an array of Jest CLI options
* @param {array} debug whether start with '--inspect-brk' or not
*/

module.exports = function createJestRunner (jestArgs, debug) {
return async function () {
const execArgv = getChildProcesExecArgv()
const args = [...execArgv, ...jestArgs]
const execArgv = getChildProcessExecArgv()
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'
})
}
}

function getChildProcesExecArgv () {
function getChildProcessExecArgv () {
const execArgv = process.execArgv.slice(0)
const inspectArgvIndex = execArgv.findIndex(argv =>
argv.includes('--inspect-brk')
Expand Down
6 changes: 4 additions & 2 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ 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$`
regex = `.*@vuepress/(${packages}|plugin-(${packages}))/.*\\.spec\\.(js|ts)$`
Copy link
Collaborator Author

@billyyyyy3320 billyyyyy3320 Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit because tests in shared-utils are .ts files.

const i = rawArgs.indexOf('-p')
rawArgs.splice(i, 2)
}
Expand All @@ -17,7 +19,7 @@ const jestRunner = createJestRunner([
'--config', 'scripts/jest.config.js',
'--runInBand',
...(regex ? [regex] : [])
])
], debug)

// ensure the basic temp files were generated
createApp({
Expand Down