Skip to content

Commit aa8704a

Browse files
authored
test(sveltekit): Unflake SvelteKit fetch proxy E2E test (#15311)
Ran both tests 100x in CI to check if the flakes are gone ([1](https://github.com/getsentry/sentry-javascript/actions/runs/13160819942/job/36729143461?pr=15311#step:14:80), [2](https://github.com/getsentry/sentry-javascript/actions/runs/13160819942/job/36729144129?pr=15311#step:14:82)). Seems so! The reason for the flake was that we didn't wait long enough until the Sentry SDK was intiialized before checking for it. closes #15269
1 parent 4b6dff7 commit aa8704a

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

dev-packages/e2e-tests/test-applications/sveltekit-2.5.0-twp/tests/sdk.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ test.describe('SDK-internal behavior', () => {
44
test('Injects fetch proxy script for SvelteKit<2.16.0', async ({ page }) => {
55
await page.goto('/');
66

7-
const sentryCarrier = await page.evaluate('typeof window.__SENTRY__');
7+
// @ts-expect-error this is defined
8+
await page.waitForFunction(() => typeof window.__SENTRY__ === 'object');
89
const proxyHandle = await page.evaluate('typeof window._sentryFetchProxy');
910

10-
// sanity check
11-
expect(sentryCarrier).toBe('object');
12-
1311
// fetch proxy script ran
1412
expect(proxyHandle).toBe('function');
1513
});

dev-packages/e2e-tests/test-applications/sveltekit-2/tests/sdk.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { waitForInitialPageload } from './utils';
44
test.describe('SDK-internal behavior', () => {
55
test("Doesn't inject fetch proxy script for SvelteKit>=2.16.0", async ({ page }) => {
66
await waitForInitialPageload(page, { route: '/' });
7-
const sentryCarrier = await page.evaluate('typeof window.__SENTRY__');
8-
const proxyHandle = await page.evaluate('typeof window._sentryFetchProxy');
97

10-
// sanity check
11-
expect(sentryCarrier).toBe('object');
8+
// @ts-expect-error this is defined
9+
await page.waitForFunction(() => typeof window.__SENTRY__ === 'object');
10+
11+
const proxyHandle = await page.evaluate('typeof window._sentryFetchProxy');
1212

1313
// fetch proxy script didn't run
1414
expect(proxyHandle).toBe('undefined');

0 commit comments

Comments
 (0)