Skip to content

Commit b4932be

Browse files
committed
test(nextjs): Simplify grace-period wait in pages-router API route test
1 parent bd5f5cd commit b4932be

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

dev-packages/e2e-tests/test-applications/nextjs-pages-dir/tests/api-route-transaction.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import { waitForTransaction } from '@sentry-internal/test-utils';
77
test('Sends exactly one transaction for a pages-router API route', async ({ request }) => {
88
const apiRouteTransactions: string[] = [];
99

10-
// Never resolves; we accumulate every matching transaction and assert on the total after a grace period.
11-
const collectorPromise = waitForTransaction('nextjs-pages-dir', transactionEvent => {
10+
// Accumulate every matching transaction and assert on the total after a grace period. This predicate never
11+
// returns true, so the promise never resolves; we just let it collect while we wait out the grace period.
12+
void waitForTransaction('nextjs-pages-dir', transactionEvent => {
1213
if (transactionEvent?.transaction === 'GET /api/endpoint') {
1314
apiRouteTransactions.push(transactionEvent.contexts?.trace?.trace_id ?? '<no-trace-id>');
1415
}
@@ -18,7 +19,7 @@ test('Sends exactly one transaction for a pages-router API route', async ({ requ
1819
const response = await request.get('/api/endpoint');
1920
expect(await response.json()).toStrictEqual({ name: 'John Doe' });
2021

21-
await Promise.race([collectorPromise, new Promise(resolve => setTimeout(resolve, 6000))]);
22+
await new Promise(resolve => setTimeout(resolve, 6000));
2223

2324
expect(apiRouteTransactions).toHaveLength(1);
2425
});

0 commit comments

Comments
 (0)