File tree Expand file tree Collapse file tree 4 files changed +22
-14
lines changed
dev-packages/node-integration-tests/suites/tracing Expand file tree Collapse file tree 4 files changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import Anthropic from '@anthropic-ai/sdk';
22import * as Sentry from '@sentry/node' ;
33import express from 'express' ;
44
5- const PORT = 3335 ;
5+ const PORT = 3333 ;
66
77function startMockAnthropicServer ( ) {
88 const app = express ( ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import { GoogleGenAI } from '@google/genai';
22import * as Sentry from '@sentry/node' ;
33import express from 'express' ;
44
5- const PORT = 3334 ;
65
76function startMockGoogleGenAIServer ( ) {
87 const app = express ( ) ;
@@ -39,7 +38,11 @@ function startMockGoogleGenAIServer() {
3938 sendChunk ( ) ;
4039 } ) ;
4140
42- return app . listen ( PORT ) ;
41+ return new Promise ( resolve => {
42+ app . listen ( server => {
43+ resolve ( server ) ;
44+ } ) ;
45+ } ) ;
4346}
4447
4548// Helper function to create mock stream
@@ -133,12 +136,12 @@ async function* createMockStream(model) {
133136}
134137
135138async function run ( ) {
136- const server = startMockGoogleGenAIServer ( ) ;
139+ const server = await startMockGoogleGenAIServer ( ) ;
137140
138141 await Sentry . startSpan ( { op : 'function' , name : 'main' } , async ( ) => {
139142 const client = new GoogleGenAI ( {
140143 apiKey : 'mock-api-key' ,
141- httpOptions : { baseUrl : `http://localhost:${ PORT } ` } ,
144+ httpOptions : { baseUrl : `http://localhost:${ server . address ( ) . port } ` } ,
142145 } ) ;
143146
144147 // Test 1: models.generateContentStream (streaming)
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import { GoogleGenAI } from '@google/genai';
22import * as Sentry from '@sentry/node' ;
33import express from 'express' ;
44
5- const PORT = 3337 ;
65
76function startMockGoogleGenAIServer ( ) {
87 const app = express ( ) ;
@@ -118,7 +117,11 @@ function startMockGoogleGenAIServer() {
118117 sendChunk ( ) ;
119118 } ) ;
120119
121- return app . listen ( PORT ) ;
120+ return new Promise ( resolve => {
121+ app . listen ( server => {
122+ resolve ( server ) ;
123+ } ) ;
124+ } ) ;
122125}
123126
124127// Helper function to create mock stream
@@ -221,12 +224,12 @@ async function* createMockToolsStream({ tools }) {
221224}
222225
223226async function run ( ) {
224- const server = startMockGoogleGenAIServer ( ) ;
227+ const server = await startMockGoogleGenAIServer ( ) ;
225228
226229 await Sentry . startSpan ( { op : 'function' , name : 'main' } , async ( ) => {
227230 const client = new GoogleGenAI ( {
228231 apiKey : 'mock-api-key' ,
229- httpOptions : { baseUrl : `http://localhost:${ PORT } ` } ,
232+ httpOptions : { baseUrl : `http://localhost:${ server . address ( ) . port } ` } ,
230233 } ) ;
231234
232235 // Test 1: Non-streaming with tools
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ import { GoogleGenAI } from '@google/genai';
22import * as Sentry from '@sentry/node' ;
33import express from 'express' ;
44
5- const PORT = 3336 ;
6-
75function startMockGoogleGenAIServer ( ) {
86 const app = express ( ) ;
97 app . use ( express . json ( ) ) ;
@@ -39,16 +37,20 @@ function startMockGoogleGenAIServer() {
3937 } ) ;
4038 } ) ;
4139
42- return app . listen ( PORT ) ;
40+ return new Promise ( resolve => {
41+ app . listen ( server => {
42+ resolve ( server ) ;
43+ } ) ;
44+ } ) ;
4345}
4446
4547async function run ( ) {
46- const server = startMockGoogleGenAIServer ( ) ;
48+ const server = await startMockGoogleGenAIServer ( ) ;
4749
4850 await Sentry . startSpan ( { op : 'function' , name : 'main' } , async ( ) => {
4951 const client = new GoogleGenAI ( {
5052 apiKey : 'mock-api-key' ,
51- httpOptions : { baseUrl : `http://localhost:${ PORT } ` } ,
53+ httpOptions : { baseUrl : `http://localhost:${ server . address ( ) . port } ` } ,
5254 } ) ;
5355
5456 // Test 1: chats.create and sendMessage flow
You can’t perform that action at this time.
0 commit comments