-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtransactions.test.ts
More file actions
99 lines (79 loc) · 2.99 KB
/
transactions.test.ts
File metadata and controls
99 lines (79 loc) · 2.99 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { expect, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';
test('Sends an HTTP transaction', async ({ baseURL }) => {
const transactionEventPromise = waitForTransaction('effect-node', transactionEvent => {
return transactionEvent?.transaction === 'http.server GET';
});
await fetch(`${baseURL}/test-success`);
const transactionEvent = await transactionEventPromise;
expect(transactionEvent.transaction).toBe('http.server GET');
});
test('Sends transaction with manual Effect span', async ({ baseURL }) => {
const transactionEventPromise = waitForTransaction('effect-node', transactionEvent => {
return (
transactionEvent?.transaction === 'http.server GET' &&
transactionEvent?.spans?.some(span => span.description === 'test-span')
);
});
await fetch(`${baseURL}/test-transaction`);
const transactionEvent = await transactionEventPromise;
expect(transactionEvent.transaction).toBe('http.server GET');
const spans = transactionEvent.spans || [];
expect(spans).toEqual([
expect.objectContaining({
description: 'test-span',
}),
]);
});
test('Sends Effect spans with correct parent-child structure', async ({ baseURL }) => {
const transactionEventPromise = waitForTransaction('effect-node', transactionEvent => {
return (
transactionEvent?.transaction === 'http.server GET' &&
transactionEvent?.spans?.some(span => span.description === 'custom-effect-span')
);
});
await fetch(`${baseURL}/test-effect-span`);
const transactionEvent = await transactionEventPromise;
expect(transactionEvent.transaction).toBe('http.server GET');
expect(transactionEvent).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
trace: expect.objectContaining({
origin: 'auto.http.effect',
}),
}),
spans: [
expect.objectContaining({
description: 'custom-effect-span',
origin: 'auto.function.effect',
}),
expect.objectContaining({
description: 'nested-span',
origin: 'auto.function.effect',
}),
],
sdk: expect.objectContaining({
name: 'sentry.javascript.effect',
packages: [
expect.objectContaining({
name: 'npm:@sentry/effect',
}),
expect.objectContaining({
name: 'npm:@sentry/node-light',
}),
],
}),
}),
);
const parentSpan = transactionEvent.spans?.[0]?.span_id;
const nestedSpan = transactionEvent.spans?.[1]?.parent_span_id;
expect(nestedSpan).toBe(parentSpan);
});
test('Sends transaction for error route', async ({ baseURL }) => {
const transactionEventPromise = waitForTransaction('effect-node', transactionEvent => {
return transactionEvent?.transaction === 'http.server GET';
});
await fetch(`${baseURL}/test-error`);
const transactionEvent = await transactionEventPromise;
expect(transactionEvent.transaction).toBe('http.server GET');
});