|
1 | 1 | import { expect, test } from '@playwright/test'; |
2 | 2 | import { waitForError, waitForTransaction } from '@sentry-internal/test-utils'; |
| 3 | +import { isDevMode } from './isDevMode'; |
3 | 4 |
|
4 | 5 | test('Should create a transaction for middleware', async ({ request }) => { |
5 | 6 | const middlewareTransactionPromise = waitForTransaction('nextjs-16', async transactionEvent => { |
@@ -58,8 +59,19 @@ test('Faulty middlewares', async ({ request }) => { |
58 | 59 | }); |
59 | 60 |
|
60 | 61 | test('Should trace outgoing fetch requests inside middleware and create breadcrumbs for it', async ({ request }) => { |
| 62 | + test.skip(isDevMode, 'The fetch requests ends up in a separate tx in dev atm'); |
61 | 63 | const middlewareTransactionPromise = waitForTransaction('nextjs-16', async transactionEvent => { |
62 | | - return transactionEvent?.transaction === 'middleware GET'; |
| 64 | + console.log(64, 'transactionEvent', transactionEvent.transaction, { |
| 65 | + spans: transactionEvent.spans, |
| 66 | + traceId: transactionEvent.contexts?.trace?.trace_id, |
| 67 | + spanId: transactionEvent.contexts?.trace?.span_id, |
| 68 | + parentSpanId: transactionEvent.contexts?.trace?.parent_span_id, |
| 69 | + data: transactionEvent.contexts?.trace?.data, |
| 70 | + }); |
| 71 | + return ( |
| 72 | + transactionEvent?.transaction === 'middleware GET' && |
| 73 | + !!transactionEvent.spans?.find(span => span.op === 'http.client') |
| 74 | + ); |
63 | 75 | }); |
64 | 76 |
|
65 | 77 | request.get('/api/endpoint-behind-middleware', { headers: { 'x-should-make-request': '1' } }).catch(() => { |
@@ -101,6 +113,7 @@ test('Should trace outgoing fetch requests inside middleware and create breadcru |
101 | 113 | }, |
102 | 114 | ]), |
103 | 115 | ); |
| 116 | + |
104 | 117 | expect(middlewareTransaction.breadcrumbs).toEqual( |
105 | 118 | expect.arrayContaining([ |
106 | 119 | { |
|
0 commit comments