-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
37 lines (30 loc) · 1.17 KB
/
test.ts
File metadata and controls
37 lines (30 loc) · 1.17 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
26
27
28
29
30
31
32
33
34
35
36
37
import { expect } from '@playwright/test';
import { sentryTest } from '../../../utils/fixtures';
import { hasDebugLogs } from '../../../utils/helpers';
sentryTest(
'should not initialize when inside a Firefox/Safari browser extension',
async ({ getLocalTestUrl, page }) => {
const errorLogs: string[] = [];
page.on('console', message => {
if (message.type() === 'error') errorLogs.push(message.text());
});
const url = await getLocalTestUrl({ testDir: __dirname });
await page.goto(url);
const isInitialized = await page.evaluate(() => {
return !!(window as any).Sentry.isInitialized();
});
const isEnabled = await page.evaluate(() => {
return !!(window as any).Sentry.getClient()?.getOptions().enabled;
});
expect(isInitialized).toEqual(true);
expect(isEnabled).toEqual(false);
if (hasDebugLogs()) {
expect(errorLogs.length).toEqual(1);
expect(errorLogs[0]).toEqual(
'[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
);
} else {
expect(errorLogs.length).toEqual(0);
}
},
);