-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtracing.server.test.ts
More file actions
46 lines (35 loc) · 1.6 KB
/
tracing.server.test.ts
File metadata and controls
46 lines (35 loc) · 1.6 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, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/nuxt';
test('sends a server action transaction on pageload', async ({ page }) => {
const transactionPromise = waitForTransaction('nuxt-3-min', transactionEvent => {
return transactionEvent.transaction.includes('GET /test-param/');
});
await page.goto('/test-param/1234');
const transaction = await transactionPromise;
expect(transaction.contexts.trace).toEqual(
expect.objectContaining({
data: expect.objectContaining({
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.http',
}),
}),
);
});
test('does not send transactions for build asset folder "_nuxt"', async ({ page }) => {
let buildAssetFolderOccurred = false;
waitForTransaction('nuxt-3-min', transactionEvent => {
if (transactionEvent.transaction?.match(/^GET \/_nuxt\//)) {
buildAssetFolderOccurred = true;
}
return false; // expects to return a boolean (but not relevant here)
});
const transactionEventPromise = waitForTransaction('nuxt-3-min', transactionEvent => {
return transactionEvent.transaction.includes('GET /test-param/');
});
await page.goto('/test-param/1234');
const transactionEvent = await transactionEventPromise;
expect(buildAssetFolderOccurred).toBe(false);
// Parametrization does not work in Nuxt 3.7 yet (only in newer versions)
expect(transactionEvent.transaction).toBe('GET /test-param/1234');
});