Skip to content

Commit 9ffb469

Browse files
nicohrubecclaude
andcommitted
test(nestjs): Add e2e coverage for the app_creation transaction
Adds a 'Sends an app_creation transaction' test to nestjs-basic for the `Create Nest App` span (NestFactory.create), which had no coverage. It's a boot-time transaction, so it uses a look-back envelope wait. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ccb8a29 commit 9ffb469

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

dev-packages/e2e-tests/test-applications/nestjs-basic/tests/transactions.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
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+
});
329

430
test('Sends an API route transaction', async ({ baseURL }) => {
531
const pageloadTransactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {

0 commit comments

Comments
 (0)