Skip to content

fix: fail to test specific package #2099

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

Merged
merged 3 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 10 additions & 4 deletions packages/@vuepress/test-utils/lib/createJestRunner.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
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} rawArgs the processed process.argv - contains '--inspect-brk' for debug
*/

module.exports = function createJestRunner (jestArgs, rawArgs) {
return async function () {
const execArgv = getChildProcesExecArgv()
const execArgv = getChildProcessExecArgv()
const args = [...execArgv, ...jestArgs]
console.log(`running node with args: ${args.join(' ')}`)
args.unshift(...rawArgs, require.resolve('jest-cli/bin/jest'))
Expand All @@ -15,7 +21,7 @@ module.exports = function createJestRunner (jestArgs) {
}
}

function getChildProcesExecArgv () {
function getChildProcessExecArgv () {
const execArgv = process.execArgv.slice(0)
const inspectArgvIndex = execArgv.findIndex(argv =>
argv.includes('--inspect-brk')
Expand Down
4 changes: 2 additions & 2 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const args = minimist(rawArgs)
let regex
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 +17,7 @@ const jestRunner = createJestRunner([
'--config', 'scripts/jest.config.js',
'--runInBand',
...(regex ? [regex] : [])
])
], rawArgs)

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