Skip to content

test(remix): Fix integration test flakes #17093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/remix/test/integration/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export const loader: LoaderFunction = async ({ request }) => {
case 'returnRedirect':
return redirect('/?type=plain');
case 'throwRedirectToExternal':
throw redirect('https://example.com');
throw redirect(`https://docs.sentry.io`);
case 'returnRedirectToExternal':
return redirect('https://example.com');
return redirect('https://docs.sentry.io');
default: {
return {};
}
Expand Down
30 changes: 11 additions & 19 deletions packages/remix/test/integration/test/client/root-loader.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Page, expect, test } from '@playwright/test';
import { type Page, expect, test, chromium } from '@playwright/test';

async function getRouteData(page: Page): Promise<any> {
return page.evaluate('window.__remixContext.state.loaderData').catch(err => {
Expand All @@ -22,7 +22,6 @@ async function extractTraceAndBaggageFromMeta(

test('should inject `sentry-trace` and `baggage` into root loader returning an empty object.', async ({ page }) => {
await page.goto('/?type=empty');

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

expect(sentryTrace).toMatch(/.+/);
Expand All @@ -38,7 +37,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning an e

test('should inject `sentry-trace` and `baggage` into root loader returning a plain object.', async ({ page }) => {
await page.goto('/?type=plain');

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

expect(sentryTrace).toMatch(/.+/);
Expand All @@ -56,7 +54,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a pl

test('should inject `sentry-trace` and `baggage` into root loader returning a `JSON response`.', async ({ page }) => {
await page.goto('/?type=json');

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

expect(sentryTrace).toMatch(/.+/);
Expand All @@ -74,7 +71,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a `J

test('should inject `sentry-trace` and `baggage` into root loader returning a deferred response', async ({ page }) => {
await page.goto('/?type=defer');

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

expect(sentryTrace).toMatch(/.+/);
Expand All @@ -90,7 +86,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a de

test('should inject `sentry-trace` and `baggage` into root loader returning `null`.', async ({ page }) => {
await page.goto('/?type=null');

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

expect(sentryTrace).toMatch(/.+/);
Expand All @@ -106,7 +101,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning `nul

test('should inject `sentry-trace` and `baggage` into root loader returning `undefined`.', async ({ page }) => {
await page.goto('/?type=undefined');

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

expect(sentryTrace).toMatch(/.+/);
Expand All @@ -124,12 +118,11 @@ test('should inject `sentry-trace` and `baggage` into root loader throwing a red
page,
}) => {
await page.goto('/?type=throwRedirect');
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

// We should be successfully redirected to the path.
expect(page.url()).toEqual(expect.stringContaining('/?type=plain'));

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

expect(sentryTrace).toMatch(/.+/);
expect(sentryBaggage).toMatch(/.+/);

Expand All @@ -143,14 +136,14 @@ test('should inject `sentry-trace` and `baggage` into root loader throwing a red

test('should inject `sentry-trace` and `baggage` into root loader returning a redirection to valid path.', async ({
page,
baseURL,
}) => {
await page.goto('/?type=returnRedirect');
await page.goto(`${baseURL}/?type=returnRedirect`);
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

// We should be successfully redirected to the path.
expect(page.url()).toEqual(expect.stringContaining('/?type=plain'));

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

expect(sentryTrace).toMatch(/.+/);
expect(sentryBaggage).toMatch(/.+/);

Expand All @@ -162,23 +155,22 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a re
});
});

test('should return redirect to an external path with no baggage and trace injected.', async ({ page }) => {
await page.goto('/?type=returnRedirectToExternal');
test('should return redirect to an external path with no baggage and trace injected.', async ({ page, baseURL }) => {
await page.goto(`${baseURL}/?type=returnRedirectToExternal`);

// We should be successfully redirected to the external path.
expect(page.url()).toEqual(expect.stringContaining('https://example.com'));
expect(page.url()).toEqual(expect.stringContaining('docs.sentry.io'));

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

expect(sentryTrace).toBeUndefined();
expect(sentryBaggage).toBeUndefined();
});

test('should throw redirect to an external path with no baggage and trace injected.', async ({ page }) => {
await page.goto('/?type=throwRedirectToExternal');
test('should throw redirect to an external path with no baggage and trace injected.', async ({ page, baseURL }) => {
await page.goto(`${baseURL}/?type=throwRedirectToExternal`);

// We should be successfully redirected to the external path.
expect(page.url()).toEqual(expect.stringContaining('https://example.com'));
expect(page.url()).toEqual(expect.stringContaining('docs.sentry.io'));

const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);

Expand Down
Loading