-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
25 lines (19 loc) · 1.03 KB
/
test.ts
File metadata and controls
25 lines (19 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import { LOADER_CONFIGS } from '../../../../utils/generatePlugin';
const bundle = process.env.PW_BUNDLE || '';
const isLazy = LOADER_CONFIGS[bundle]?.lazy;
sentryTest('always calls onLoad init correctly', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
await page.goto(url);
// We want to test that if we are _not_ lazy, we are correctly calling onLoad init()
// But if we are lazy and call `forceLoad`, we also call the onLoad init() correctly
if (isLazy) {
expect(await page.evaluate('window.__sentryOnLoad')).toEqual(0);
await page.evaluate('Sentry.forceLoad()');
}
await page.waitForFunction('window.__sentryOnLoad && window.sentryIsLoaded()');
expect(await page.evaluate('window.__hadSentry')).toEqual(false);
expect(await page.evaluate('window.__sentryOnLoad')).toEqual(1);
expect(await page.evaluate('Sentry.getClient().getOptions().sampleRate')).toEqual(0.5);
});