@@ -42,36 +42,39 @@ const createRunner = runPath => {
42
42
onFailure ,
43
43
options ,
44
44
) {
45
+ const mutex = throat ( 1 ) ;
45
46
return tests . reduce (
46
47
( promise , test ) =>
47
- promise
48
- . then ( ( ) => {
49
- if ( watcher . isInterrupted ( ) ) {
50
- throw new CancelRun ( ) ;
51
- }
52
-
53
- return onStart ( test ) . then ( ( ) => {
54
- // eslint-disable-next-line import/no-dynamic-require, global-require
55
- const runner = require ( runPath ) ;
56
- const baseOptions = {
57
- config : test . context . config ,
58
- globalConfig : this . _globalConfig ,
59
- testPath : test . path ,
60
- rawModuleMap : watcher . isWatchMode ( )
61
- ? test . context . moduleMap . getRawModuleMap ( )
62
- : null ,
63
- options,
64
- } ;
65
-
66
- if ( typeof runner . default === 'function' ) {
67
- return runner . default ( baseOptions ) ;
48
+ mutex ( ( ) =>
49
+ promise
50
+ . then ( ( ) => {
51
+ if ( watcher . isInterrupted ( ) ) {
52
+ throw new CancelRun ( ) ;
68
53
}
69
54
70
- return runner ( baseOptions ) ;
71
- } ) ;
72
- } )
73
- . then ( result => onResult ( test , result ) )
74
- . catch ( err => onFailure ( test , err ) ) ,
55
+ return onStart ( test ) . then ( ( ) => {
56
+ // eslint-disable-next-line import/no-dynamic-require, global-require
57
+ const runner = require ( runPath ) ;
58
+ const baseOptions = {
59
+ config : test . context . config ,
60
+ globalConfig : this . _globalConfig ,
61
+ testPath : test . path ,
62
+ rawModuleMap : watcher . isWatchMode ( )
63
+ ? test . context . moduleMap . getRawModuleMap ( )
64
+ : null ,
65
+ options,
66
+ } ;
67
+
68
+ if ( typeof runner . default === 'function' ) {
69
+ return runner . default ( baseOptions ) ;
70
+ }
71
+
72
+ return runner ( baseOptions ) ;
73
+ } ) ;
74
+ } )
75
+ . then ( result => onResult ( test , result ) )
76
+ . catch ( err => onFailure ( test , err ) ) ,
77
+ ) ,
75
78
Promise . resolve ( ) ,
76
79
) ;
77
80
}
0 commit comments