-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathtest.ts
47 lines (34 loc) · 1.63 KB
/
test.ts
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
import { expect } from '@playwright/test';
import { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
sentryTest('should create a navigation transaction on page navigation', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
const pageloadRequest = await getFirstSentryEnvelopeRequest<Event>(page, url);
const navigationRequest = await getFirstSentryEnvelopeRequest<Event>(page, `${url}#foo`);
expect(pageloadRequest.contexts?.trace.op).toBe('pageload');
expect(navigationRequest.contexts?.trace.op).toBe('navigation');
expect(navigationRequest.transaction_info?.source).toEqual('url');
const pageloadTraceId = pageloadRequest.contexts?.trace.trace_id;
const navigationTraceId = navigationRequest.contexts?.trace.trace_id;
expect(pageloadTraceId).toBeDefined();
expect(navigationTraceId).toBeDefined();
expect(pageloadTraceId).not.toEqual(navigationTraceId);
const pageloadSpans = pageloadRequest.spans;
const navigationSpans = navigationRequest.spans;
const pageloadSpanId = pageloadRequest.contexts?.trace.span_id;
const navigationSpanId = navigationRequest.contexts?.trace.span_id;
expect(pageloadSpanId).toBeDefined();
expect(navigationSpanId).toBeDefined();
pageloadSpans?.forEach(span =>
expect(span).toMatchObject({
parent_span_id: pageloadSpanId,
}),
);
navigationSpans?.forEach(span =>
expect(span).toMatchObject({
parent_span_id: navigationSpanId,
}),
);
expect(pageloadSpanId).not.toEqual(navigationSpanId);
});