Skip to content

Commit 56b2b9f

Browse files
committed
Add middleware file to nextjs-13 e2e tests to demonstrate failure
1 parent 2f3eca9 commit 56b2b9f

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { NextResponse } from 'next/server';
2+
3+
export function middleware() {
4+
// Basic middleware to ensure that the build works with edge runtime
5+
return NextResponse.next();
6+
}

dev-packages/e2e-tests/test-applications/nextjs-13/tests/server/cjs-api-endpoints.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ test('should create a transaction for a CJS pages router API endpoint', async ({
1111
const transactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
1212
return (
1313
transactionEvent.transaction === 'GET /api/cjs-api-endpoint' &&
14-
transactionEvent.contexts?.trace?.op === 'http.server'
14+
transactionEvent.contexts?.trace?.op === 'http.server' &&
15+
transactionEvent.transaction_info?.source === 'route'
1516
);
1617
});
1718

@@ -73,7 +74,8 @@ test('should not mess up require statements in CJS API endpoints', async ({ requ
7374
const transactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
7475
return (
7576
transactionEvent.transaction === 'GET /api/cjs-api-endpoint-with-require' &&
76-
transactionEvent.contexts?.trace?.op === 'http.server'
77+
transactionEvent.contexts?.trace?.op === 'http.server' &&
78+
transactionEvent.transaction_info?.source === 'route'
7779
);
7880
});
7981

dev-packages/e2e-tests/test-applications/nextjs-13/tests/server/wrapApiHandlerWithSentry.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ const cases = [
2222
cases.forEach(({ name, url, transactionName }) => {
2323
test(`Should capture transactions for routes with various shapes (${name})`, async ({ request }) => {
2424
const transactionEventPromise = waitForTransaction('nextjs-13', transactionEvent => {
25-
return transactionEvent.transaction === transactionName && transactionEvent.contexts?.trace?.op === 'http.server';
25+
return (
26+
transactionEvent.transaction === transactionName &&
27+
transactionEvent.contexts?.trace?.op === 'http.server' &&
28+
transactionEvent.transaction_info?.source === 'route'
29+
);
2630
});
2731

2832
request.get(url).catch(() => {

0 commit comments

Comments
 (0)