|
1 | 1 | import { expect, test } from '@playwright/test'; |
2 | | -import { waitForTransaction } from '@sentry-internal/test-utils'; |
| 2 | +import { waitForEnvelopeItem, waitForTransaction } from '@sentry-internal/test-utils'; |
| 3 | + |
| 4 | +test('Sends an app_creation transaction', async () => { |
| 5 | + // The app_creation span is emitted once at startup (NestFactory.create), before any request is |
| 6 | + // made, so we look back through the buffered envelopes rather than waiting for a new transaction. |
| 7 | + const envelopeItem = await waitForEnvelopeItem( |
| 8 | + 'nestjs-basic', |
| 9 | + item => item[0].type === 'transaction' && (item[1] as { transaction?: string }).transaction === 'Create Nest App', |
| 10 | + 0, |
| 11 | + ); |
| 12 | + |
| 13 | + const transaction = envelopeItem[1] as { |
| 14 | + contexts: { trace: { op?: string; origin?: string; data?: Record<string, unknown> } }; |
| 15 | + }; |
| 16 | + |
| 17 | + expect(transaction.contexts.trace.op).toBe('app_creation.nestjs'); |
| 18 | + expect(transaction.contexts.trace.origin).toBe('auto.http.otel.nestjs'); |
| 19 | + expect(transaction.contexts.trace.data).toEqual( |
| 20 | + expect.objectContaining({ |
| 21 | + component: '@nestjs/core', |
| 22 | + 'nestjs.type': 'app_creation', |
| 23 | + 'nestjs.module': 'AppModule', |
| 24 | + 'sentry.op': 'app_creation.nestjs', |
| 25 | + 'sentry.origin': 'auto.http.otel.nestjs', |
| 26 | + }), |
| 27 | + ); |
| 28 | +}); |
3 | 29 |
|
4 | 30 | test('Sends an API route transaction', async ({ baseURL }) => { |
5 | 31 | const pageloadTransactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => { |
|
0 commit comments