@@ -7,11 +7,14 @@ import {
7
7
vendorTask , sequenceTask , serverTask
8
8
} from '../task_helpers' ;
9
9
10
+ const gulpRunSequence = require ( 'run-sequence' ) ;
10
11
11
12
const appDir = path . join ( SOURCE_ROOT , 'e2e-app' ) ;
12
13
const outDir = DIST_ROOT ;
13
14
const PROTRACTOR_CONFIG_PATH = path . join ( PROJECT_ROOT , 'test/protractor.conf.js' ) ;
14
15
16
+ /** Method to stop a running e2e web server, which may have not exited properly */
17
+ let stopE2eServer = ( ) => { } ;
15
18
16
19
task ( ':watch:e2eapp' , ( ) => {
17
20
watch ( path . join ( appDir , '**/*.ts' ) , [ ':build:e2eapp:ts' ] ) ;
@@ -39,17 +42,6 @@ task(':test:protractor:setup', execNodeTask('protractor', 'webdriver-manager', [
39
42
/** Runs protractor tests (assumes that server is already running. */
40
43
task ( ':test:protractor' , execNodeTask ( 'protractor' , [ PROTRACTOR_CONFIG_PATH ] ) ) ;
41
44
42
- /**
43
- * Forces process termination.
44
- *
45
- * This task is used because, in some cases, protractor will block and not exit the process,
46
- * causing Travis to timeout. This task should always be used in a synchronous sequence as
47
- * the last step.
48
- */
49
- task ( ':e2e:done' , ( ) => process . exit ( 0 ) ) ;
50
-
51
- let stopE2eServer : ( ) => void = null ;
52
-
53
45
/** Starts up the e2e app server. */
54
46
task ( ':serve:e2eapp' , serverTask ( false , stream => { stopE2eServer = ( ) => stream . emit ( 'kill' ) ; } ) ) ;
55
47
@@ -70,23 +62,27 @@ task('serve:e2eapp:watch', ['serve:e2eapp', ':watch:components', ':watch:e2eapp'
70
62
*
71
63
* This task should only be used when running the e2e tests locally.
72
64
*/
73
- task ( 'e2e' , sequenceTask (
74
- ':test:protractor:setup' ,
75
- 'serve:e2eapp:watch' ,
76
- ':test:protractor' ,
77
- ':serve:e2eapp:stop' ,
78
- ':e2e:done' ,
79
- ) ) ;
65
+ task ( 'e2e' , ( done : ( err ?: string ) => void ) => {
66
+ gulpRunSequence (
67
+ ':test:protractor:setup' ,
68
+ 'serve:e2eapp:watch' ,
69
+ ':test:protractor' ,
70
+ ':serve:e2eapp:stop' ,
71
+ ( err : any ) => stopE2eServer ( ) && done ( err )
72
+ ) ;
73
+ } ) ;
80
74
81
75
/**
82
76
* Runs the e2e once. Does not watch for changes.
83
77
*
84
78
* This task should be used when running tests on the CI server.
85
79
*/
86
- task ( 'e2e:single-run' , sequenceTask (
87
- ':test:protractor:setup' ,
88
- 'serve:e2eapp' ,
89
- ':test:protractor' ,
90
- ':serve:e2eapp:stop' ,
91
- ':e2e:done' ,
92
- ) ) ;
80
+ task ( 'e2e:single-run' , ( done : ( err ?: string ) => void ) => {
81
+ gulpRunSequence (
82
+ ':test:protractor:setup' ,
83
+ 'serve:e2eapp' ,
84
+ ':test:protractor' ,
85
+ ':serve:e2eapp:stop' ,
86
+ ( err : any ) => stopE2eServer ( ) && done ( err )
87
+ ) ;
88
+ } ) ;
0 commit comments