From 30ca8b3357c0b9171f8e4cd34885b13f7ba8aeb3 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 18 Mar 2022 14:28:41 -0400 Subject: [PATCH] use waitForSelector instead of waitForFunction to work around CSP heisenbug (#4385) --- packages/kit/test/utils.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/kit/test/utils.js b/packages/kit/test/utils.js index 4d84a8fafad0..46b1404ed832 100644 --- a/packages/kit/test/utils.js +++ b/packages/kit/test/utils.js @@ -98,10 +98,8 @@ export const test = base.extend({ if (javaScriptEnabled) { page.addInitScript({ content: ` - window.started = false; - addEventListener('sveltekit:start', () => { - window.started = true; + document.body.classList.add('started'); }); ` }); @@ -116,7 +114,7 @@ export const test = base.extend({ async function (url, opts) { const res = await goto.call(page, url, opts); if (javaScriptEnabled) { - await page.waitForFunction(() => window.started, undefined, { timeout: 5000 }); + await page.waitForSelector('body.started', { timeout: 5000 }); } return res; };