@@ -8,10 +8,10 @@ import { log } from 'utils/logger'
8
8
const run = path => {
9
9
Checker . ensure ( )
10
10
if ( ! path || path . match ( / f e a t u r e s / ) ) {
11
- buildAndRun ( path )
11
+ return buildAndRun ( path )
12
12
} else {
13
13
log ( chalk . bold ( 'Running test suite...' ) )
14
- runUnitTests ( path )
14
+ return runUnitTests ( path )
15
15
}
16
16
}
17
17
@@ -26,25 +26,34 @@ const buildAndRun = path => {
26
26
}
27
27
28
28
const runFeatureTests = path => {
29
- spawnSync ( 'npx' , [ 'jest' , '-i' , path ] , {
29
+ const result = spawnSync ( 'npx' , [ 'jest' , '-i' , path ] , {
30
30
env : nodeEnv ( 'test' ) ,
31
31
shell : true ,
32
32
stdio : 'inherit'
33
33
} )
34
+ return buildPromise ( result . status )
34
35
}
35
36
36
37
const runUnitTests = path => {
37
- spawnSync ( 'npx' , [ 'jest' , path ] , {
38
+ const result = spawnSync ( 'npx' , [ 'jest' , path ] , {
38
39
env : nodeEnv ( 'test' ) ,
39
40
shell : true ,
40
41
stdio : 'inherit'
41
42
} )
43
+ return buildPromise ( result . status )
42
44
}
43
45
44
46
const runAllTests = ( ) => {
45
- runUnitTests ( './test/units' )
46
- runFeatureTests ( './test/features' )
47
- return Promise . resolve ( )
47
+ return Promise . all ( [
48
+ runUnitTests ( './test/units' ) ,
49
+ runFeatureTests ( './test/features' )
50
+ ] )
51
+ }
52
+
53
+ const buildPromise = status => {
54
+ return ( status === 0 )
55
+ ? Promise . resolve ( )
56
+ : Promise . reject ( Error ( 'Some tests failed' ) )
48
57
}
49
58
50
59
export const TestRunner = { run }
0 commit comments