-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
47 lines (40 loc) · 1.49 KB
/
test.ts
File metadata and controls
47 lines (40 loc) · 1.49 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
import type { Route } from '@playwright/test';
import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../../utils/helpers';
sentryTest(
'should ignore mark and measure spans that match `ignoreMeasureSpans`',
async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
await page.route('**/path/to/script.js', (route: Route) =>
route.fulfill({ path: `${__dirname}/assets/script.js` }),
);
const url = await getLocalTestUrl({ testDir: __dirname });
const transactionRequestPromise = waitForTransactionRequest(
page,
evt => evt.type === 'transaction' && evt.contexts?.trace?.op === 'pageload',
);
await page.goto(url);
const transactionEvent = envelopeRequestParser(await transactionRequestPromise);
const markAndMeasureSpans = transactionEvent.spans?.filter(({ op }) => op && ['mark', 'measure'].includes(op));
expect(markAndMeasureSpans?.length).toBe(3);
expect(markAndMeasureSpans).toEqual(
expect.arrayContaining([
expect.objectContaining({
description: 'mark-pass',
op: 'mark',
}),
expect.objectContaining({
description: 'measure-pass',
op: 'measure',
}),
expect.objectContaining({
description: 'sentry-tracing-init',
op: 'mark',
}),
]),
);
},
);