|
| 1 | +import { expect, test } from '@nuxt/test-utils/playwright'; |
| 2 | +import { waitForTransaction } from '@sentry-internal/test-utils'; |
| 3 | +import type { Span } from '@sentry/nuxt'; |
| 4 | + |
| 5 | +test('sends a pageload root span with a parameterized URL', async ({ page }) => { |
| 6 | + const transactionPromise = waitForTransaction('nuxt-3', async transactionEvent => { |
| 7 | + return transactionEvent.transaction === '/test-param/:param()'; |
| 8 | + }); |
| 9 | + |
| 10 | + await page.goto(`/test-param/1234`); |
| 11 | + |
| 12 | + const rootSpan = await transactionPromise; |
| 13 | + |
| 14 | + expect(rootSpan).toMatchObject({ |
| 15 | + contexts: { |
| 16 | + trace: { |
| 17 | + data: { |
| 18 | + 'sentry.source': 'route', |
| 19 | + 'sentry.origin': 'auto.pageload.vue', |
| 20 | + 'sentry.op': 'pageload', |
| 21 | + 'params.param': '1234', |
| 22 | + }, |
| 23 | + op: 'pageload', |
| 24 | + origin: 'auto.pageload.vue', |
| 25 | + }, |
| 26 | + }, |
| 27 | + transaction: '/test-param/:param()', |
| 28 | + transaction_info: { |
| 29 | + source: 'route', |
| 30 | + }, |
| 31 | + }); |
| 32 | +}); |
| 33 | + |
| 34 | +test('sends component tracking spans when `trackComponents` is enabled', async ({ page }) => { |
| 35 | + const transactionPromise = waitForTransaction('nuxt-3', async transactionEvent => { |
| 36 | + return transactionEvent.transaction === '/client-error'; |
| 37 | + }); |
| 38 | + |
| 39 | + await page.goto(`/client-error`); |
| 40 | + |
| 41 | + const rootSpan = await transactionPromise; |
| 42 | + const errorButtonSpan = rootSpan.spans.find((span: Span) => span.description === 'Vue <ErrorButton>'); |
| 43 | + |
| 44 | + const expected = { |
| 45 | + data: { 'sentry.origin': 'auto.ui.vue', 'sentry.op': 'ui.vue.mount' }, |
| 46 | + description: 'Vue <ErrorButton>', |
| 47 | + op: 'ui.vue.mount', |
| 48 | + parent_span_id: expect.any(String), |
| 49 | + span_id: expect.any(String), |
| 50 | + start_timestamp: expect.any(Number), |
| 51 | + timestamp: expect.any(Number), |
| 52 | + trace_id: expect.any(String), |
| 53 | + origin: 'auto.ui.vue', |
| 54 | + }; |
| 55 | + |
| 56 | + expect(errorButtonSpan).toMatchObject(expected); |
| 57 | +}); |
0 commit comments