-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
46 lines (36 loc) · 1.79 KB
/
test.ts
File metadata and controls
46 lines (36 loc) · 1.79 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
38
39
40
41
42
43
44
45
46
import { expect } from '@playwright/test';
import { sentryTest } from '../../../utils/fixtures';
import { waitForSession } from '../../../utils/helpers';
sentryTest('should update session when an error is thrown.', async ({ getLocalTestUrl, page }) => {
const pageloadSessionPromise = waitForSession(page, s => !!s.init && s.status === 'ok');
const url = await getLocalTestUrl({ testDir: __dirname });
await page.goto(url);
const pageloadSession = await pageloadSessionPromise;
const updatedSessionPromise = waitForSession(page, s => !s.init);
await page.locator('#throw-error').click();
const updatedSession = await updatedSessionPromise;
expect(pageloadSession).toBeDefined();
expect(pageloadSession.init).toBe(true);
expect(pageloadSession.errors).toBe(0);
expect(updatedSession.init).toBe(false);
expect(updatedSession.errors).toBe(1);
expect(updatedSession.status).toBe('crashed');
expect(pageloadSession.sid).toBe(updatedSession.sid);
});
sentryTest('should update session when an exception is captured.', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
const pageloadSessionPromise = waitForSession(page, s => !!s.init && s.status === 'ok');
await page.goto(url);
const pageloadSession = await pageloadSessionPromise;
const updatedSessionPromise = waitForSession(page);
await page.locator('#capture-exception').click();
const updatedSession = await updatedSessionPromise;
expect(pageloadSession).toBeDefined();
expect(pageloadSession.init).toBe(true);
expect(pageloadSession.errors).toBe(0);
expect(updatedSession).toBeDefined();
expect(updatedSession.init).toBe(false);
expect(updatedSession.errors).toBe(1);
expect(updatedSession.status).toBe('ok');
expect(pageloadSession.sid).toBe(updatedSession.sid);
});