1
1
#! /usr/bin/env node
2
2
/* eslint-disable-next-line no-unused-vars */
3
3
import serve from "./server.mjs" ;
4
- import { Builder , Capabilities } from "selenium-webdriver" ;
4
+ import { Builder , Capabilities } from "selenium-webdriver" ;
5
5
import commandLineArgs from "command-line-args" ;
6
6
import commandLineUsage from "command-line-usage" ;
7
7
@@ -63,6 +63,7 @@ switch (BROWSER) {
63
63
printHelp ( `Invalid browser "${ BROWSER } ", choices are: "safari", "firefox", "chrome", "edge"` ) ;
64
64
}
65
65
}
66
+
66
67
process . on ( "unhandledRejection" , ( err ) => {
67
68
console . error ( err ) ;
68
69
process . exit ( 1 ) ;
@@ -76,9 +77,7 @@ const PORT = options.port;
76
77
const server = await serve ( PORT ) ;
77
78
78
79
async function testEnd2End ( ) {
79
- const driver = await new Builder ( )
80
- . withCapabilities ( capabilities )
81
- . build ( ) ;
80
+ const driver = await new Builder ( ) . withCapabilities ( capabilities ) . build ( ) ;
82
81
let results ;
83
82
try {
84
83
console . log ( "Preparing JetStream" ) ;
@@ -90,7 +89,8 @@ async function testEnd2End() {
90
89
if ( globalThis ?. JetStream ?. isReady )
91
90
callback ( )
92
91
} ) ;
93
- results = await benchmarkResults ( driver )
92
+ results = await benchmarkResults ( driver ) ;
93
+ // FIXME: validate results;
94
94
} finally {
95
95
console . log ( "\nTests complete!" ) ;
96
96
driver . quit ( ) ;
@@ -112,33 +112,31 @@ async function benchmarkResults(driver) {
112
112
} ) ;
113
113
JetStream . start ( ) ;
114
114
} ) ;
115
-
116
115
await new Promise ( resolve => pollIncrementalResults ( driver , resolve ) ) ;
117
116
const resultString = await driver . executeScript ( ( ) => {
118
- if ( globalThis . JetStreamDone )
119
- return JSON . stringify ( JetStream . resultsObject ( ) ) ;
117
+ return JSON . stringify ( JetStream . resultsObject ( ) ) ;
120
118
} ) ;
121
119
return JSON . parse ( resultString ) ;
122
120
}
123
121
124
122
const UPDATE_INTERVAL = 250 ;
125
123
async function pollIncrementalResults ( driver , resolve ) {
126
- const internalId = setInterval ( async function logResult ( ) {
124
+ const intervalId = setInterval ( async function logResult ( ) {
127
125
const { done, results} = await driver . executeAsyncScript ( ( callback ) => {
128
126
callback ( {
129
127
done : globalThis . JetStreamDone ,
130
128
results : JSON . stringify ( globalThis . JetStreamResults . splice ( 0 , Infinity ) )
131
129
} ) ;
132
130
} ) ;
133
- JSON . parse ( results ) . forEach ( logBenchmarkResult ) ;
131
+ JSON . parse ( results ) . forEach ( logIncrementalResult ) ;
134
132
if ( done ) {
135
- clearInterval ( internalId ) ;
133
+ clearInterval ( intervalId ) ;
136
134
resolve ( )
137
135
}
138
136
} , UPDATE_INTERVAL )
139
137
}
140
138
141
- function logBenchmarkResult ( benchmarkResult ) {
139
+ function logIncrementalResult ( benchmarkResult ) {
142
140
console . log ( benchmarkResult . name , benchmarkResult . results )
143
141
}
144
142
0 commit comments