Commit 0aadf05 1 parent e9fde5c commit 0aadf05 Copy full SHA for 0aadf05
File tree 2 files changed +16
-8
lines changed
packages/@vuepress/test-utils/lib
2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 1
1
const execa = require ( 'execa' )
2
- const rawArgs = process . argv . slice ( 2 )
3
2
4
3
const usedPorts = [ ]
5
4
6
- module . exports = function createJestRunner ( jestArgs ) {
5
+ /**
6
+ * Run jest
7
+ *
8
+ * @param {array } jestArgs an array of Jest CLI options
9
+ * @param {array } debug whether start with '--inspect-brk' or not
10
+ */
11
+
12
+ module . exports = function createJestRunner ( jestArgs , debug ) {
7
13
return async function ( ) {
8
- const execArgv = getChildProcesExecArgv ( )
9
- const args = [ ...execArgv , ...jestArgs ]
14
+ const execArgv = getChildProcessExecArgv ( )
15
+ const args = [ require . resolve ( 'jest-cli/bin/jest' ) , ...execArgv , ...jestArgs ]
16
+ if ( debug ) args . unshift ( '--inspect-brk' )
10
17
console . log ( `running node with args: ${ args . join ( ' ' ) } ` )
11
- args . unshift ( ...rawArgs , require . resolve ( 'jest-cli/bin/jest' ) )
12
18
await execa ( 'node' , args , {
13
19
stdio : 'inherit'
14
20
} )
15
21
}
16
22
}
17
23
18
- function getChildProcesExecArgv ( ) {
24
+ function getChildProcessExecArgv ( ) {
19
25
const execArgv = process . execArgv . slice ( 0 )
20
26
const inspectArgvIndex = execArgv . findIndex ( argv =>
21
27
argv . includes ( '--inspect-brk' )
Original file line number Diff line number Diff line change @@ -6,9 +6,11 @@ const rawArgs = process.argv.slice(2)
6
6
const args = minimist ( rawArgs )
7
7
8
8
let regex
9
+ const debug = ! ! args [ 'inspect-brk' ]
10
+
9
11
if ( args . p ) {
10
12
const packages = ( args . p || args . package ) . split ( ',' ) . join ( '|' )
11
- regex = `.*@vuepress/(${ packages } |plugin-(${ packages } ))/.*\\.spec\\.js $`
13
+ regex = `.*@vuepress/(${ packages } |plugin-(${ packages } ))/.*\\.spec\\.(js|ts) $`
12
14
const i = rawArgs . indexOf ( '-p' )
13
15
rawArgs . splice ( i , 2 )
14
16
}
@@ -17,7 +19,7 @@ const jestRunner = createJestRunner([
17
19
'--config' , 'scripts/jest.config.js' ,
18
20
'--runInBand' ,
19
21
...( regex ? [ regex ] : [ ] )
20
- ] )
22
+ ] , debug )
21
23
22
24
// ensure the basic temp files were generated
23
25
createApp ( {
You can’t perform that action at this time.
0 commit comments