1
- var q = require ( 'q' ) ;
2
- var webdriver = require ( 'selenium-webdriver' ) ;
3
-
4
- var RunnerReporter = function ( emitter ) {
1
+ let RunnerReporter = function ( emitter ) {
5
2
this . emitter = emitter ;
6
3
this . testResult = [ ] ,
7
4
this . failedCount = 0 ;
@@ -18,7 +15,7 @@ RunnerReporter.prototype.specStarted = function() {
18
15
} ;
19
16
20
17
RunnerReporter . prototype . specDone = function ( result ) {
21
- var specInfo = {
18
+ let specInfo = {
22
19
name : result . description ,
23
20
category : result . fullName . slice ( 0 , - result . description . length ) . trim ( )
24
21
} ;
@@ -29,7 +26,7 @@ RunnerReporter.prototype.specDone = function(result) {
29
26
this . failedCount ++ ;
30
27
}
31
28
32
- var entry = {
29
+ let entry = {
33
30
description : result . fullName ,
34
31
assertions : [ ] ,
35
32
duration : new Date ( ) . getTime ( ) - this . startTime . getTime ( )
@@ -41,7 +38,7 @@ RunnerReporter.prototype.specDone = function(result) {
41
38
} ) ;
42
39
}
43
40
44
- result . failedExpectations . forEach ( function ( item ) {
41
+ result . failedExpectations . forEach ( item => {
45
42
entry . assertions . push ( {
46
43
passed : item . passed ,
47
44
errorMsg : item . passed ? undefined : item . message ,
@@ -56,23 +53,20 @@ RunnerReporter.prototype.specDone = function(result) {
56
53
*
57
54
* @param {Runner } runner The current Protractor Runner.
58
55
* @param {Array } specs Array of Directory Path Strings.
59
- * @return {q. Promise } Promise resolved with the test results
56
+ * @return {Promise } Promise resolved with the test results
60
57
*/
61
- exports . run = function ( runner , specs ) {
62
- var JasmineRunner = require ( 'jasmine' ) ;
63
- var jrunner = new JasmineRunner ( ) ;
64
- /* global jasmine */
65
-
66
- require ( 'jasminewd2' ) . init ( webdriver . promise . controlFlow ( ) , webdriver ) ;
58
+ exports . run = async function ( runner , specs ) {
59
+ const JasmineRunner = require ( 'jasmine' ) ;
60
+ let jrunner = new JasmineRunner ( ) ;
67
61
68
- var jasmineNodeOpts = runner . getConfig ( ) . jasmineNodeOpts ;
62
+ let jasmineNodeOpts = runner . getConfig ( ) . jasmineNodeOpts ;
69
63
70
64
// On timeout, the flow should be reset. This will prevent webdriver tasks
71
65
// from overflowing into the next test and causing it to fail or timeout
72
66
// as well. This is done in the reporter instead of an afterEach block
73
67
// to ensure that it runs after any afterEach() blocks with webdriver tasks
74
68
// get to complete first.
75
- var reporter = new RunnerReporter ( runner ) ;
69
+ let reporter = new RunnerReporter ( runner ) ;
76
70
jasmine . getEnv ( ) . addReporter ( reporter ) ;
77
71
78
72
// Add hooks for afterEach
@@ -100,36 +94,32 @@ exports.run = function(runner, specs) {
100
94
}
101
95
}
102
96
103
- return runner . runTestPreparer ( ) . then ( function ( ) {
104
- return q . promise ( function ( resolve , reject ) {
105
- if ( jasmineNodeOpts && jasmineNodeOpts . defaultTimeoutInterval ) {
106
- jasmine . DEFAULT_TIMEOUT_INTERVAL = jasmineNodeOpts . defaultTimeoutInterval ;
107
- }
97
+ await runner . runTestPreparer ( ) ;
98
+ return new Promise ( ( resolve , reject ) => {
99
+ if ( jasmineNodeOpts && jasmineNodeOpts . defaultTimeoutInterval ) {
100
+ jasmine . DEFAULT_TIMEOUT_INTERVAL = jasmineNodeOpts . defaultTimeoutInterval ;
101
+ }
108
102
109
- var originalOnComplete = runner . getConfig ( ) . onComplete ;
110
-
111
- jrunner . onComplete ( function ( passed ) {
112
- try {
113
- var completed = q ( ) ;
114
- if ( originalOnComplete ) {
115
- completed = q ( originalOnComplete ( passed ) ) ;
116
- }
117
- completed . then ( function ( ) {
118
- resolve ( {
119
- failedCount : reporter . failedCount ,
120
- specResults : reporter . testResult
121
- } ) ;
122
- } ) ;
123
- } catch ( err ) {
124
- reject ( err ) ;
125
- }
126
- } ) ;
103
+ let originalOnComplete = runner . getConfig ( ) . onComplete ;
127
104
128
- jrunner . configureDefaultReporter ( jasmineNodeOpts ) ;
129
- jrunner . projectBaseDir = '' ;
130
- jrunner . specDir = '' ;
131
- jrunner . addSpecFiles ( specs ) ;
132
- jrunner . execute ( ) ;
105
+ jrunner . onComplete ( async ( passed ) => {
106
+ try {
107
+ if ( originalOnComplete ) {
108
+ await originalOnComplete ( passed ) ;
109
+ }
110
+ resolve ( {
111
+ failedCount : reporter . failedCount ,
112
+ specResults : reporter . testResult
113
+ } ) ;
114
+ } catch ( err ) {
115
+ reject ( err ) ;
116
+ }
133
117
} ) ;
118
+
119
+ jrunner . configureDefaultReporter ( jasmineNodeOpts ) ;
120
+ jrunner . projectBaseDir = '' ;
121
+ jrunner . specDir = '' ;
122
+ jrunner . addSpecFiles ( specs ) ;
123
+ jrunner . execute ( ) ;
134
124
} ) ;
135
125
} ;
0 commit comments