Skip to content

Commit b3d5482

Browse files
committed
update loader
1 parent f9e5af8 commit b3d5482

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Sentry.onLoad(function () {
2+
// You _have_ to call Sentry.init() before calling Sentry.captureException() in Sentry.onLoad()!
23
Sentry.init();
34
Sentry.captureException('Test exception');
45
});

packages/browser-integration-tests/loader-suites/loader/onLoad/onLoadLate/init.js

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Sentry.forceLoad();
2+
3+
setTimeout(() => {
4+
Sentry.onLoad(function () {
5+
Sentry.captureException('Test exception');
6+
});
7+
}, 200);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';
5+
6+
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+
15+
const url = await getLocalTestUrl({ testDir: __dirname });
16+
const req = await waitForErrorRequestOnUrl(page, url);
17+
18+
const eventData = envelopeRequestParser(req);
19+
20+
expect(eventData.message).toBe('Test exception');
21+
});

0 commit comments

Comments
 (0)