Skip to content

Commit

Permalink
test(sveltekit): Unflake SvelteKit fetch proxy E2E test (#15311)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Lms24 authored Feb 5, 2025
1 parent 4b6dff7 commit aa8704a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ test.describe('SDK-internal behavior', () => {
test('Injects fetch proxy script for SvelteKit<2.16.0', async ({ page }) => {
await page.goto('/');

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

// sanity check
expect(sentryCarrier).toBe('object');

// fetch proxy script ran
expect(proxyHandle).toBe('function');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { waitForInitialPageload } from './utils';
test.describe('SDK-internal behavior', () => {
test("Doesn't inject fetch proxy script for SvelteKit>=2.16.0", async ({ page }) => {
await waitForInitialPageload(page, { route: '/' });
const sentryCarrier = await page.evaluate('typeof window.__SENTRY__');
const proxyHandle = await page.evaluate('typeof window._sentryFetchProxy');

// sanity check
expect(sentryCarrier).toBe('object');
// @ts-expect-error this is defined
await page.waitForFunction(() => typeof window.__SENTRY__ === 'object');

const proxyHandle = await page.evaluate('typeof window._sentryFetchProxy');

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

0 comments on commit aa8704a

Please sign in to comment.