File tree 5 files changed +98
-7
lines changed
5 files changed +98
-7
lines changed Original file line number Diff line number Diff line change 12
12
13
13
var spawn = require ( 'cross-spawn' ) ;
14
14
var script = process . argv [ 2 ] ;
15
- var args = process . argv . slice ( 3 ) ;
15
+ var getArgs = require ( '../scripts/utils/getSubscriptArgs' ) ;
16
16
17
17
switch ( script ) {
18
18
case 'build' :
19
19
case 'eject' :
20
20
case 'start' :
21
21
case 'test' :
22
- var result = spawn . sync (
23
- 'node' ,
24
- [ require . resolve ( '../scripts/' + script ) ] . concat ( args ) ,
25
- { stdio : 'inherit' }
26
- ) ;
22
+ var scriptFilename = require . resolve ( '../scripts/' + script ) ;
23
+ var result = spawn . sync ( 'node' , getArgs ( scriptFilename ) , {
24
+ stdio : 'inherit' ,
25
+ } ) ;
27
26
if ( result . signal ) {
28
27
if ( result . signal === 'SIGKILL' ) {
29
28
console . log (
Original file line number Diff line number Diff line change @@ -13,4 +13,5 @@ const babelJest = require('babel-jest');
13
13
module . exports = babelJest . createTransformer ( {
14
14
presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
15
15
babelrc : false ,
16
+ sourceMaps : process . env . REACT_APP_DEBUG_JEST ? 'inline' : false ,
16
17
} ) ;
Original file line number Diff line number Diff line change 8
8
* of patent rights can be found in the PATENTS file in the same directory.
9
9
*/
10
10
// @remove -on-eject-end
11
+
12
+ /**
13
+ * Greetings! If you are here attempting to start a debugging session, please
14
+ * ensure that your debugger of choice is configured to enable source maps,
15
+ * otherwise your code may appear mangled by babel!
16
+ */
11
17
'use strict' ;
12
18
19
+ var debugArgs = require ( './utils/debugArgs' ) ;
20
+
13
21
process . env . NODE_ENV = 'test' ;
14
22
process . env . PUBLIC_URL = '' ;
15
23
@@ -27,13 +35,23 @@ process.on('unhandledRejection', err => {
27
35
require ( 'dotenv' ) . config ( { silent : true } ) ;
28
36
29
37
const jest = require ( 'jest' ) ;
30
- const argv = process . argv . slice ( 2 ) ;
38
+ let argv = process . argv . slice ( 2 ) ;
39
+ const isDebug = ! ! process . env . REACT_APP_DEBUG_JEST ;
40
+ const isRunInBand = argv . indexOf ( '--runInBand' ) > - 1 || argv . indexOf ( '-i' ) > - 1 ;
31
41
32
42
// Watch unless on CI or in coverage mode
33
43
if ( ! process . env . CI && argv . indexOf ( '--coverage' ) < 0 ) {
34
44
argv . push ( '--watch' ) ;
35
45
}
36
46
47
+ // Force debug into single worker
48
+ if ( isDebug ) {
49
+ if ( ! isRunInBand ) {
50
+ argv . push ( '--runInBand' ) ;
51
+ }
52
+ argv = debugArgs . removeFrom ( argv ) ;
53
+ }
54
+
37
55
// @remove -on-eject-begin
38
56
// This is not necessary after eject because we embed config into package.json.
39
57
const createJestConfig = require ( './utils/createJestConfig' ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+ 'use strict' ;
10
+
11
+ const DEBUG_FLAGS = [
12
+ / ^ d e b u g $ / ,
13
+ / ^ - - d e b u g $ / ,
14
+ / ^ - - d e b u g - b r k ( = \d + ) ? $ / ,
15
+ / ^ - - i n s p e c t $ / ,
16
+ / ^ - - i n s p e c t - b r k ( = \d + ) ? $ / ,
17
+ ] ;
18
+
19
+ module . exports = {
20
+ _match : function _matchDebugFlags ( args , onMatch ) {
21
+ for ( var i in args ) {
22
+ if ( args . hasOwnProperty ( i ) ) {
23
+ for ( var j in DEBUG_FLAGS ) {
24
+ if ( DEBUG_FLAGS . hasOwnProperty ( j ) ) {
25
+ if ( args [ i ] . match ( DEBUG_FLAGS [ j ] ) ) {
26
+ onMatch ( args [ i ] ) ;
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ } ,
33
+ getFrom : function getDebugFlags ( args ) {
34
+ var matches = [ ] ;
35
+ this . _match ( args , function addMatch ( arg ) {
36
+ matches . push ( arg ) ;
37
+ } ) ;
38
+ return matches . length ? matches : null ;
39
+ } ,
40
+ removeFrom : function removeDebugFlags ( args ) {
41
+ var matches = this . getFrom ( args ) || [ ] ;
42
+ return args . filter ( function isNotDebugArg ( arg ) {
43
+ return ! matches . some ( function isPresent ( debugArg ) {
44
+ return arg === debugArg ;
45
+ } ) ;
46
+ } ) ;
47
+ } ,
48
+ } ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+ 'use strict' ;
10
+
11
+ var debugArgs = require ( '../utils/debugArgs' ) ;
12
+
13
+ module . exports = function getSubscriptArgs ( scriptFilename ) {
14
+ var args = process . argv . slice ( 3 ) ;
15
+ var passedDebugArgs ;
16
+ var nonDebugArgs ;
17
+ args . unshift ( scriptFilename ) ;
18
+ passedDebugArgs = debugArgs . getFrom ( args ) ;
19
+ if ( passedDebugArgs ) {
20
+ process . env . REACT_APP_DEBUG_JEST = 'true' ; // :eyes: side-effect
21
+ nonDebugArgs = debugArgs . removeFrom ( args ) ;
22
+ args = passedDebugArgs . concat ( nonDebugArgs ) ;
23
+ }
24
+ return args ;
25
+ } ;
You can’t perform that action at this time.
0 commit comments