Skip to content

Commit 6a86a33

Browse files
committed
Try mocking the example route
1 parent a86ca4e commit 6a86a33

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/remix/test/integration/test/client/root-loader.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ async function extractTraceAndBaggageFromMeta(
2020
return { sentryTrace: sentryTraceContent, sentryBaggage: sentryBaggageContent };
2121
}
2222

23+
async function mockExampleRoute(page: Page): Promise<void> {
24+
await page.route('https://example.com/**/*', route => {
25+
return route.fulfill({
26+
status: 200,
27+
body: JSON.stringify({
28+
foo: 'bar',
29+
}),
30+
});
31+
});
32+
}
33+
2334
test('should inject `sentry-trace` and `baggage` into root loader returning an empty object.', async ({ page }) => {
2435
await page.goto('/?type=empty');
2536

@@ -123,6 +134,7 @@ test('should inject `sentry-trace` and `baggage` into root loader returning `und
123134
test('should inject `sentry-trace` and `baggage` into root loader throwing a redirection to a plain object.', async ({
124135
page,
125136
}) => {
137+
await mockExampleRoute(page);
126138
await page.goto('/?type=throwRedirect');
127139

128140
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
@@ -144,6 +156,7 @@ test('should inject `sentry-trace` and `baggage` into root loader throwing a red
144156
test('should inject `sentry-trace` and `baggage` into root loader returning a redirection to valid path.', async ({
145157
page,
146158
}) => {
159+
await mockExampleRoute(page);
147160
await page.goto('/?type=returnRedirect');
148161

149162
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
@@ -163,6 +176,7 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a re
163176
});
164177

165178
test('should return redirect to an external path with no baggage and trace injected.', async ({ page }) => {
179+
await mockExampleRoute(page);
166180
await page.goto('/?type=returnRedirectToExternal');
167181

168182
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta(page);
@@ -175,6 +189,7 @@ test('should return redirect to an external path with no baggage and trace injec
175189
});
176190

177191
test('should throw redirect to an external path with no baggage and trace injected.', async ({ page }) => {
192+
await mockExampleRoute(page);
178193
await page.goto('/?type=throwRedirectToExternal');
179194

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

0 commit comments

Comments
 (0)