@@ -70,21 +70,6 @@ async function runMochaAsync(mocha) {
70
70
return new Promise ( resolve => mocha . run ( resolve ) ) ;
71
71
}
72
72
73
- async function maybeExtractMochaStatsDump ( msg ) {
74
- if ( msg . args ( ) . length == 1 && msg . text ( ) . startsWith ( "{" ) ) {
75
- const arg = await msg . args ( ) [ 0 ] . jsonValue ( ) ;
76
- let obj ;
77
- try {
78
- obj = JSON . parse ( arg ) ;
79
- } catch ( e ) {
80
- return ;
81
- }
82
- if ( obj . hasOwnProperty ( "stats" ) ) {
83
- return obj ;
84
- }
85
- }
86
- }
87
-
88
73
const PORT = process . env . PORT ?? 50123 ;
89
74
const OPEN_DEVTOOLS = ! ! process . env . OPEN_DEVTOOLS ;
90
75
@@ -107,11 +92,12 @@ async function getNumFailingTestsInPuppeteer() {
107
92
}
108
93
} ) ;
109
94
95
+ // If we want DevTools open, wait for a second here so DevTools can load.
96
+ // Otherwise we might run past `debugger` statements.
110
97
if ( OPEN_DEVTOOLS ) {
111
- // If we want DevTools open, wait for a second here so DevTools can load.
112
- // Otherwise we might run past `debugger` statements.
113
98
await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
114
99
}
100
+
115
101
const app = Express ( ) ;
116
102
app . use ( "/" , Express . static ( "../" ) ) ;
117
103
const server = app . listen ( PORT ) ;
@@ -125,9 +111,10 @@ async function getNumFailingTestsInPuppeteer() {
125
111
suitePaths.push(${ JSON . stringify ( testFile ) } );
126
112
` ) ;
127
113
}
128
- const script = document . createElement ( "script" ) ;
114
+
129
115
// Create a promise that resolves once mocha is done running.
130
116
// This way we can block this `evaluate` call until mocha is done.
117
+ const script = document . createElement ( "script" ) ;
131
118
script . innerHTML = `
132
119
self.mochaRun = new Promise(resolve => mocha.run(resolve));` ;
133
120
document . body . append ( script ) ;
@@ -148,3 +135,18 @@ async function getNumFailingTestsInPuppeteer() {
148
135
}
149
136
return numFailures ;
150
137
}
138
+
139
+ async function maybeExtractMochaStatsDump ( msg ) {
140
+ if ( msg . args ( ) . length == 1 && msg . text ( ) . startsWith ( "{" ) ) {
141
+ const arg = await msg . args ( ) [ 0 ] . jsonValue ( ) ;
142
+ let obj ;
143
+ try {
144
+ obj = JSON . parse ( arg ) ;
145
+ } catch ( e ) {
146
+ return ;
147
+ }
148
+ if ( obj . hasOwnProperty ( "stats" ) ) {
149
+ return obj ;
150
+ }
151
+ }
152
+ }
0 commit comments