Skip to content

Commit 9e676e0

Browse files
authored
test(browser-integration): Add sentry DSN route handler by default (#14095)
Instead of sprinkling this through tests, we can just generally handle this route, streamlining tests a bit and avoid unexpected errors/console warnings messing with things. So this PR basically inverses this - by default, we add a "success" route handler for the Sentry DSN, and if you want to have special handling you can opt-out of this. Supersedes https://github.com/getsentry/sentry-javascript/pull/14092/files
1 parent c7378e6 commit 9e676e0

File tree

102 files changed

+45
-1141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+45
-1141
lines changed

dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/replay/test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ sentryTest('should capture a replay', async ({ getLocalTestUrl, page }) => {
1111
sentryTest.skip();
1212
}
1313

14-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
15-
return route.fulfill({
16-
status: 200,
17-
contentType: 'application/json',
18-
body: JSON.stringify({ id: 'test-id' }),
19-
});
20-
});
21-
2214
const req = waitForReplayRequest(page);
2315

2416
const url = await getLocalTestUrl({ testDir: __dirname });

dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/replayError/test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ sentryTest('should capture a replay & attach an error', async ({ getLocalTestUrl
99
sentryTest.skip();
1010
}
1111

12-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
13-
return route.fulfill({
14-
status: 200,
15-
contentType: 'application/json',
16-
body: JSON.stringify({ id: 'test-id' }),
17-
});
18-
});
19-
2012
const req = waitForReplayRequest(page);
2113

2214
const url = await getLocalTestUrl({ testDir: __dirname });

dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/sdkLoadedInMeanwhile/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sentryTest('it does not download the SDK if the SDK was loaded in the meanwhile'
2828
});
2929
});
3030

31-
const tmpDir = await getLocalTestUrl({ testDir: __dirname, skipRouteHandler: true });
31+
const tmpDir = await getLocalTestUrl({ testDir: __dirname, skipRouteHandler: true, skipDsnRouteHandler: true });
3232

3333
await page.route(`${TEST_HOST}/*.*`, route => {
3434
const file = route.request().url().split('/').pop();

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/captureExceptionInOnLoad/test.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ import { sentryTest } from '../../../../utils/fixtures';
44
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
55

66
sentryTest('captureException works inside of onLoad', async ({ getLocalTestUrl, page }) => {
7-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
8-
return route.fulfill({
9-
status: 200,
10-
contentType: 'application/json',
11-
body: JSON.stringify({ id: 'test-id' }),
12-
});
13-
});
14-
157
const url = await getLocalTestUrl({ testDir: __dirname });
168
const req = await waitForErrorRequestOnUrl(page, url);
179

@@ -21,14 +13,6 @@ sentryTest('captureException works inside of onLoad', async ({ getLocalTestUrl,
2113
});
2214

2315
sentryTest('should set SENTRY_SDK_SOURCE value', async ({ getLocalTestUrl, page }) => {
24-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
25-
return route.fulfill({
26-
status: 200,
27-
contentType: 'application/json',
28-
body: JSON.stringify({ id: 'test-id' }),
29-
});
30-
});
31-
3216
const url = await getLocalTestUrl({ testDir: __dirname });
3317
const req = await waitForErrorRequestOnUrl(page, url);
3418

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customInit/test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ const bundle = process.env.PW_BUNDLE || '';
77
const isLazy = LOADER_CONFIGS[bundle]?.lazy;
88

99
sentryTest('always calls onLoad init correctly', async ({ getLocalTestUrl, page }) => {
10-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
11-
return route.fulfill({
12-
status: 200,
13-
contentType: 'application/json',
14-
body: JSON.stringify({ id: 'test-id' }),
15-
});
16-
});
17-
1810
const url = await getLocalTestUrl({ testDir: __dirname });
1911

2012
await page.goto(url);

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrations/test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ sentryTest('should handle custom added integrations & default integrations', asy
88
const shouldHaveReplay = !shouldSkipReplayTest();
99
const shouldHaveBrowserTracing = !shouldSkipTracingTest();
1010

11-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
12-
return route.fulfill({
13-
status: 200,
14-
contentType: 'application/json',
15-
body: JSON.stringify({ id: 'test-id' }),
16-
});
17-
});
18-
1911
const url = await getLocalTestUrl({ testDir: __dirname });
2012
await page.goto(url);
2113

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrationsFunction/test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ import { sentryTest } from '../../../../utils/fixtures';
55
sentryTest(
66
'should not add default integrations if integrations function is provided',
77
async ({ getLocalTestUrl, page }) => {
8-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
9-
return route.fulfill({
10-
status: 200,
11-
contentType: 'application/json',
12-
body: JSON.stringify({ id: 'test-id' }),
13-
});
14-
});
15-
168
const url = await getLocalTestUrl({ testDir: __dirname });
179
await page.goto(url);
1810

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customReplay/test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ sentryTest('should handle custom added Replay integration', async ({ getLocalTes
88
sentryTest.skip();
99
}
1010

11-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
12-
return route.fulfill({
13-
status: 200,
14-
contentType: 'application/json',
15-
body: JSON.stringify({ id: 'test-id' }),
16-
});
17-
});
18-
1911
const req = waitForReplayRequest(page);
2012

2113
const url = await getLocalTestUrl({ testDir: __dirname });

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/keepSentryGlobal/test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ import { sentryTest } from '../../../../utils/fixtures';
44
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
55

66
sentryTest('keeps data on window.Sentry intact', async ({ getLocalTestUrl, page }) => {
7-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
8-
return route.fulfill({
9-
status: 200,
10-
contentType: 'application/json',
11-
body: JSON.stringify({ id: 'test-id' }),
12-
});
13-
});
14-
157
const url = await getLocalTestUrl({ testDir: __dirname });
168
const req = await waitForErrorRequestOnUrl(page, url);
179

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/onLoadLate/test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ import { sentryTest } from '../../../../utils/fixtures';
44
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
55

66
sentryTest('late onLoad call is handled', async ({ getLocalTestUrl, page }) => {
7-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
8-
return route.fulfill({
9-
status: 200,
10-
contentType: 'application/json',
11-
body: JSON.stringify({ id: 'test-id' }),
12-
});
13-
});
14-
157
const url = await getLocalTestUrl({ testDir: __dirname });
168
const req = await waitForErrorRequestOnUrl(page, url);
179

0 commit comments

Comments
 (0)