Skip to content

Commit cd75340

Browse files
committed
fix(browsers): ensuring acknowledgement is only necessary for browserstack
- short and quick selenium runs can send all xhr requests before the acknowledger can get lined up to listen for them. This was the case with jquery-mousewheel, which has been added in the tests.
1 parent e52e26f commit cd75340

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "test/jquery-ui"]
88
path = test/jquery-ui
99
url = [email protected]:jquery/jquery-ui.git
10+
[submodule "test/jquery-mousewheel"]
11+
path = test/jquery-mousewheel
12+
url = [email protected]:jquery/jquery-mousewheel.git

browsers.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,16 @@ export async function createBrowserWorker( url, browser, options, restarts = 0 )
103103
worker.browser = browser;
104104
worker.restarts = restarts;
105105
worker.options = options;
106-
touchBrowser( browser );
106+
107107
workers[ fullBrowser ] = worker;
108+
touchBrowser( browser );
108109

109-
// Wait for the worker to show up in the list
110-
// before returning it.
111-
return ensureAcknowledged( worker );
110+
// Wait for at least one response
111+
// from the worker before continuing
112+
if ( browserstack ) {
113+
await ensureAcknowledged( worker );
114+
}
115+
return worker;
112116
}
113117

114118
export function touchBrowser( browser ) {

createTestServer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export async function createTestServer( {
159159
".txt": "text/plain",
160160
".log": "text/plain"
161161
};
162+
162163
use( async( req, res, next ) => {
163164

164165
// Allow serving anything but node_modules,

run.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ export async function run( {
8080
quiet: true, // Quiet server logs during test runs
8181
testUrls,
8282
report: async( message ) => {
83+
const reportId = message.id;
84+
const report = reports[ reportId ];
85+
touchBrowser( report.browser );
86+
8387
switch ( message.type ) {
8488
case "testEnd": {
85-
const reportId = message.id;
86-
const report = reports[ reportId ];
87-
touchBrowser( report.browser );
8889
const errorMessage = reportTest( message.data, report );
8990
pendingErrors[ reportId ] ??= Object.create( null );
9091
if ( errorMessage ) {
@@ -107,18 +108,12 @@ export async function run( {
107108
break;
108109
}
109110
case "error": {
110-
const reportId = message.id;
111-
const report = reports[ reportId ];
112-
touchBrowser( report.browser );
113111
const errorMessage = reportError( message.data );
114112
pendingErrors[ reportId ] ??= Object.create( null );
115113
pendingErrors[ reportId ][ message.data.message ] = errorMessage;
116114
break;
117115
}
118116
case "runEnd": {
119-
const reportId = message.id;
120-
const report = reports[ reportId ];
121-
touchBrowser( report.browser );
122117
const { failed, total } = reportEnd( message.data, reports[ reportId ] );
123118
report.total = total;
124119

@@ -144,11 +139,6 @@ export async function run( {
144139
// Run the next test
145140
return getNextBrowserTest( reportId );
146141
}
147-
case "ack": {
148-
const report = reports[ message.id ];
149-
touchBrowser( report.browser );
150-
break;
151-
}
152142
default:
153143
console.warn( "Received unknown message type:", message.type );
154144
}
@@ -340,16 +330,16 @@ export async function run( {
340330
}
341331
} finally {
342332
console.log();
343-
if ( errorMessages.length === 0 ) {
333+
const numErrors = errorMessages.length;
334+
if ( numErrors === 0 ) {
344335
let stop = false;
345336
for ( const report of Object.values( reports ) ) {
346337
if ( !report.total ) {
347338
stop = true;
348339
console.error(
349340
chalk.red(
350-
`No tests were run with URL "${ report.url }" in ${
351-
report.fullBrowser
352-
} (${ report.id })`
341+
`No tests were run with URL "${ report.url }" ` +
342+
`in ${ report.fullBrowser } (${ report.id })`
353343
)
354344
);
355345
}
@@ -363,8 +353,9 @@ export async function run( {
363353
gracefulExit( 0 );
364354
}
365355
} else {
366-
const len = errorMessages.length;
367-
console.error( chalk.red( `${ len } test${ len > 1 ? "s" : "" } failed.` ) );
356+
console.error(
357+
chalk.red( `${ numErrors } test${ numErrors > 1 ? "s" : "" } failed.` )
358+
);
368359
console.log(
369360
errorMessages.map( ( error, i ) => `\n${ i + 1 }. ${ error }` ).join( "\n" )
370361
);

test/jquery-mousewheel

Submodule jquery-mousewheel added at cf816bd

0 commit comments

Comments
 (0)