Skip to content

Commit b2ef44f

Browse files
committed
test(node): Avoid using specific port for node-integration-tests
1 parent 61b3f97 commit b2ef44f

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import Anthropic from '@anthropic-ai/sdk';
22
import * as Sentry from '@sentry/node';
33
import express from 'express';
44

5-
const PORT = 3333;
6-
75
function startMockAnthropicServer() {
86
const app = express();
97
app.use(express.json());
@@ -50,7 +48,7 @@ function startMockAnthropicServer() {
5048
},
5149
});
5250
});
53-
return app.listen(PORT);
51+
return app.listen();
5452
}
5553

5654
async function run() {
@@ -59,7 +57,7 @@ async function run() {
5957
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
6058
const client = new Anthropic({
6159
apiKey: 'mock-api-key',
62-
baseURL: `http://localhost:${PORT}/anthropic`,
60+
baseURL: `http://localhost:${server.address().port}/anthropic`,
6361
});
6462

6563
// First test: basic message completion

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { GoogleGenAI } from '@google/genai';
22
import * as Sentry from '@sentry/node';
33
import express from 'express';
44

5-
const PORT = 3333;
6-
75
function startMockGoogleGenAIServer() {
86
const app = express();
97
app.use(express.json());
@@ -39,7 +37,7 @@ function startMockGoogleGenAIServer() {
3937
});
4038
});
4139

42-
return app.listen(PORT);
40+
return app.listen();
4341
}
4442

4543
async function run() {
@@ -48,7 +46,7 @@ async function run() {
4846
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
4947
const client = new GoogleGenAI({
5048
apiKey: 'mock-api-key',
51-
httpOptions: { baseUrl: `http://localhost:${PORT}` },
49+
httpOptions: { baseUrl: `http://localhost:${server.address().port}` },
5250
});
5351

5452
// Test 1: chats.create and sendMessage flow

dev-packages/node-integration-tests/suites/tracing/openai/scenario-root-span.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import express from 'express';
22
import OpenAI from 'openai';
33

4-
const PORT = 3333;
5-
64
function startMockOpenAiServer() {
75
const app = express();
86
app.use(express.json());
@@ -31,14 +29,14 @@ function startMockOpenAiServer() {
3129
},
3230
});
3331
});
34-
return app.listen(PORT);
32+
return app.listen();
3533
}
3634

3735
async function run() {
3836
const server = startMockOpenAiServer();
3937

4038
const client = new OpenAI({
41-
baseURL: `http://localhost:${PORT}/openai`,
39+
baseURL: `http://localhost:${server.address().port}/openai`,
4240
apiKey: 'mock-api-key',
4341
});
4442

0 commit comments

Comments
 (0)