Skip to content

Commit a945362

Browse files
committed
Add middleware file to nextjs-13 e2e tests to demonstrate failure
1 parent a991c3f commit a945362

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
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(() => {

dev-packages/node-integration-tests/suites/tracing/anthropic/instrument-with-pii.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@ Sentry.init({
88
tracesSampleRate: 1.0,
99
sendDefaultPii: true,
1010
transport: loggingTransport,
11-
integrations: [
12-
Sentry.anthropicAIIntegration(),
13-
nodeContextIntegration(),
14-
],
11+
integrations: [Sentry.anthropicAIIntegration(), nodeContextIntegration()],
1512
});

dev-packages/node-integration-tests/suites/tracing/anthropic/instrument.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,5 @@ Sentry.init({
99
sendDefaultPii: false,
1010
transport: loggingTransport,
1111
// Force include the integration
12-
integrations: [
13-
Sentry.anthropicAIIntegration(),
14-
nodeContextIntegration(),
15-
],
12+
integrations: [Sentry.anthropicAIIntegration(), nodeContextIntegration()],
1613
});

dev-packages/node-integration-tests/suites/tracing/anthropic/scenario-stream.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,3 @@ async function run() {
101101
}
102102

103103
run();
104-
105-

dev-packages/node-integration-tests/suites/tracing/anthropic/scenario.mjs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class MockAnthropic {
88
// Create messages object with create and countTokens methods
99
this.messages = {
1010
create: this._messagesCreate.bind(this),
11-
countTokens: this._messagesCountTokens.bind(this)
11+
countTokens: this._messagesCountTokens.bind(this),
1212
};
1313

1414
this.models = {
@@ -56,8 +56,8 @@ class MockAnthropic {
5656

5757
// For countTokens, just return input_tokens
5858
return {
59-
input_tokens: 15
60-
}
59+
input_tokens: 15,
60+
};
6161
}
6262

6363
async _modelsRetrieve(modelId) {
@@ -69,7 +69,7 @@ class MockAnthropic {
6969
id: modelId,
7070
name: modelId,
7171
created_at: 1715145600,
72-
model: modelId, // Add model field to match the check in addResponseAttributes
72+
model: modelId, // Add model field to match the check in addResponseAttributes
7373
};
7474
}
7575
}
@@ -86,9 +86,7 @@ async function run() {
8686
await client.messages.create({
8787
model: 'claude-3-haiku-20240307',
8888
system: 'You are a helpful assistant.',
89-
messages: [
90-
{ role: 'user', content: 'What is the capital of France?' },
91-
],
89+
messages: [{ role: 'user', content: 'What is the capital of France?' }],
9290
temperature: 0.7,
9391
max_tokens: 100,
9492
});
@@ -106,9 +104,7 @@ async function run() {
106104
// Third test: count tokens with cached tokens
107105
await client.messages.countTokens({
108106
model: 'claude-3-haiku-20240307',
109-
messages: [
110-
{ role: 'user', content: 'What is the capital of France?' },
111-
],
107+
messages: [{ role: 'user', content: 'What is the capital of France?' }],
112108
});
113109

114110
// Fourth test: models.retrieve

0 commit comments

Comments
 (0)