From b637ce12507a64d7bb974404a0123ed2e46f5d0c Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 15 Jul 2022 13:06:19 -0700 Subject: [PATCH] test: skip tests that modify env in non-default mode (#15725) --- tests/library/chromium/chromium.spec.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/library/chromium/chromium.spec.ts b/tests/library/chromium/chromium.spec.ts index dca6186140..7517e5a17f 100644 --- a/tests/library/chromium/chromium.spec.ts +++ b/tests/library/chromium/chromium.spec.ts @@ -639,6 +639,7 @@ test.describe('should emit page-level network events with service worker fetch h }); test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => { + test.skip(({ mode }) => mode !== 'default', 'Cannot set env variables in non-default'); test.beforeAll(() => process.env.PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS = '1'); test.afterAll(() => delete process.env.PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS); @@ -841,7 +842,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => { res.write(` + `); res.end(); }); @@ -850,11 +851,11 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => { res.write(` self.addEventListener("fetch", (event) => { // actually make the request - const responsePromise = fetch(event.request); + const responsePromise = fetch(event.request); // send it back to the page event.respondWith(responsePromise); }); - + self.addEventListener("activate", (event) => { event.waitUntil(clients.claim()); }); @@ -904,7 +905,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => { res.write(` + `); res.end(); }); @@ -919,7 +920,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => { }) ); }); - + // Opt to handle FetchEvent's from the page self.addEventListener("fetch", (event) => { event.respondWith( @@ -927,23 +928,23 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => { // 1. Try to first serve directly from caches let response = await caches.match(event.request); if (response) return response; - + // 2. Re-write request for /foo to /bar if (event.request.url.endsWith("foo")) return fetch("./bar"); - + // 3. Prevent tracker.js from being retrieved, and returns a placeholder response if (event.request.url.endsWith("tracker.js")) return new Response('conosole.log("no trackers!")', { status: 200, headers: { "Content-Type": "text/javascript" }, }); - + // 4. Otherwise, fallthrough, perform the fetch and respond return fetch(event.request); })() ); }); - + self.addEventListener("activate", (event) => { event.waitUntil(clients.claim()); }); @@ -1028,7 +1029,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => { evt.preventDefault(); registration.then(r => r.update()); }); - + const registration = new Promise(r => navigator.serviceWorker.register('/worker.js').then(r)); registration.then(() => updateBtn.disabled = false);