@@ -13,8 +13,76 @@ const createRunner = runPath => {
13
13
this . _globalConfig = globalConfig ;
14
14
}
15
15
16
- // eslint-disable-next-line
17
16
runTests ( tests , watcher , onStart , onResult , onFailure , options ) {
17
+ return options . serial
18
+ ? this . _createInBandTestRun (
19
+ tests ,
20
+ watcher ,
21
+ onStart ,
22
+ onResult ,
23
+ onFailure ,
24
+ options ,
25
+ )
26
+ : this . _createParallelTestRun (
27
+ tests ,
28
+ watcher ,
29
+ onStart ,
30
+ onResult ,
31
+ onFailure ,
32
+ options ,
33
+ ) ;
34
+ }
35
+
36
+ _createInBandTestRun (
37
+ tests ,
38
+ watcher ,
39
+ onStart ,
40
+ onResult ,
41
+ onFailure ,
42
+ options ,
43
+ ) {
44
+ return tests . reduce (
45
+ ( promise , test ) =>
46
+ promise
47
+ . then ( ( ) => {
48
+ if ( watcher . isInterrupted ( ) ) {
49
+ throw new CancelRun ( ) ;
50
+ }
51
+
52
+ return onStart ( test ) . then ( ( ) => {
53
+ // eslint-disable-next-line import/no-dynamic-require, global-require
54
+ const runner = require ( runPath ) ;
55
+ const baseOptions = {
56
+ config : test . context . config ,
57
+ globalConfig : this . _globalConfig ,
58
+ testPath : test . path ,
59
+ rawModuleMap : watcher . isWatchMode ( )
60
+ ? test . context . moduleMap . getRawModuleMap ( )
61
+ : null ,
62
+ options,
63
+ } ;
64
+
65
+ if ( typeof runner . default === 'function' ) {
66
+ return runner . default ( baseOptions ) ;
67
+ }
68
+
69
+ return runner ( baseOptions ) ;
70
+ } ) ;
71
+ } )
72
+ . then ( result => onResult ( test , result ) )
73
+ . catch ( err => onFailure ( test , err ) ) ,
74
+ Promise . resolve ( ) ,
75
+ ) ;
76
+ }
77
+
78
+ _createParallelTestRun (
79
+ tests ,
80
+ watcher ,
81
+ onStart ,
82
+ onResult ,
83
+ onFailure ,
84
+ options ,
85
+ ) {
18
86
const worker = new Worker ( runPath , {
19
87
exposedMethods : [ 'default' ] ,
20
88
numWorkers : this . _globalConfig . maxWorkers ,
0 commit comments