-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
48 lines (40 loc) · 1.54 KB
/
test.ts
File metadata and controls
48 lines (40 loc) · 1.54 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
47
48
import { expect } from '@playwright/test';
import { sentryTest } from '../../../utils/fixtures';
import { waitForSession } from '../../../utils/helpers';
sentryTest('starts a new session on pageload.', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
const sessionPromise = waitForSession(page, s => !!s.init && s.status === 'ok');
await page.goto(url);
const session = await sessionPromise;
expect(session).toBeDefined();
expect(session).toEqual({
attrs: {
environment: 'production',
release: '0.1',
user_agent: expect.any(String),
},
did: '1337',
errors: 0,
init: true,
sid: expect.any(String),
started: expect.any(String),
status: 'ok',
timestamp: expect.any(String),
});
});
sentryTest('starts a new session with navigation.', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
const initSessionPromise = waitForSession(page, s => !!s.init && s.status === 'ok');
await page.goto(url);
const initSession = await initSessionPromise;
const newSessionPromise = waitForSession(page, s => !!s.init && s.status === 'ok');
await page.locator('#navigate').click();
const newSession = await newSessionPromise;
expect(newSession).toBeDefined();
expect(newSession.init).toBe(true);
expect(newSession.errors).toBe(0);
expect(newSession.status).toBe('ok');
expect(newSession.sid).toBeDefined();
expect(initSession.sid).not.toBe(newSession.sid);
expect(newSession.did).toBe('1337');
});