Skip to content

Commit 386cd2b

Browse files
committed
ref: Update loader & add test for integrations-function
1 parent 470c1c6 commit 386cd2b

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

packages/browser-integration-tests/fixtures/loader.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
class CustomIntegration {
6+
constructor() {
7+
this.name = 'CustomIntegration';
8+
}
9+
10+
setupOnce() {}
11+
}
12+
13+
Sentry.onLoad(function () {
14+
Sentry.init({
15+
integrations: integrations => [new CustomIntegration()].concat(integrations),
16+
});
17+
18+
window.__sentryLoaded = true;
19+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Sentry.forceLoad();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
5+
sentryTest(
6+
'should not add default integrations if integrations function is provided',
7+
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+
16+
const url = await getLocalTestUrl({ testDir: __dirname });
17+
await page.goto(url);
18+
19+
await page.waitForFunction(() => {
20+
return (window as any).__sentryLoaded;
21+
});
22+
23+
const hasCustomIntegration = await page.evaluate(() => {
24+
return !!(window as any).Sentry.getCurrentHub().getClient().getIntegrationById('CustomIntegration');
25+
});
26+
27+
const hasReplay = await page.evaluate(() => {
28+
return !!(window as any).Sentry.getCurrentHub().getClient().getIntegrationById('Replay');
29+
});
30+
const hasBrowserTracing = await page.evaluate(() => {
31+
return !!(window as any).Sentry.getCurrentHub().getClient().getIntegrationById('BrowserTracing');
32+
});
33+
34+
expect(hasCustomIntegration).toEqual(true);
35+
expect(hasReplay).toEqual(false);
36+
expect(hasBrowserTracing).toEqual(false);
37+
},
38+
);

0 commit comments

Comments
 (0)