From 80cc83d0aabd9545aaaf1cf7c78d1933a463b694 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Thu, 26 Oct 2023 09:17:33 -0500 Subject: [PATCH] chore: fix test flake with shared workers and correlating on failures (#28132) Co-authored-by: Cacie Prins --- packages/server/test/integration/http_requests_spec.js | 3 ++- system-tests/projects/e2e/shared-worker.js | 10 +++++----- system-tests/projects/e2e/web-worker.js | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index 5eed3127763b..1fa37e332fe5 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -1035,7 +1035,7 @@ describe('Routes', () => { this.networkProxy.setPreRequestTimeout(50) // If this takes longer than the Promise.delay and the prerequest timeout then the second // call has hit the prerequest timeout which is a problem - this.timeout(150) + this.timeout(900) nock(this.server.remoteStates.current().origin) .get('/') @@ -1057,6 +1057,7 @@ describe('Routes', () => { // Wait 100 ms to make sure the request times out return Promise.delay(100).then(() => { + this.networkProxy.setPreRequestTimeout(1000) nock(this.server.remoteStates.current().origin) .get('/') .once() diff --git a/system-tests/projects/e2e/shared-worker.js b/system-tests/projects/e2e/shared-worker.js index 8db062f6ecd9..1ff369a5e391 100644 --- a/system-tests/projects/e2e/shared-worker.js +++ b/system-tests/projects/e2e/shared-worker.js @@ -1,14 +1,14 @@ -// eslint-disable-next-line no-undef -importScripts('/sw.js') - -self.addEventListener('connect', (event) => { +self.onconnect = (event) => { const port = event.ports[0] port.onmessage = (e) => { + // eslint-disable-next-line no-undef + importScripts('/sw.js') + if (e.data.foo === 'baz') { port.postMessage({ foo: 'baz2', }) } } -}) +} diff --git a/system-tests/projects/e2e/web-worker.js b/system-tests/projects/e2e/web-worker.js index 31781f7a4bb9..a086e041b114 100644 --- a/system-tests/projects/e2e/web-worker.js +++ b/system-tests/projects/e2e/web-worker.js @@ -1,7 +1,7 @@ -// eslint-disable-next-line no-undef -importScripts('/ww.js') - onmessage = (e) => { + // eslint-disable-next-line no-undef + importScripts('/ww.js') + if (e.data.foo === 'bar') { postMessage({ foo: 'bar2',