diff --git a/packages/node/test/integrations/undici.test.ts b/packages/node/test/integrations/undici.test.ts index bf2169bc3967..f2587f75f463 100644 --- a/packages/node/test/integrations/undici.test.ts +++ b/packages/node/test/integrations/undici.test.ts @@ -15,8 +15,8 @@ let hub: Hub; let fetch: typeof FetchType; beforeAll(async () => { - await setupTestServer(); try { + await setupTestServer(); // need to conditionally require `undici` because it's not available in Node 10 // eslint-disable-next-line @typescript-eslint/no-var-requires fetch = require('undici').fetch; @@ -51,10 +51,10 @@ conditionalTest({ min: 16 })('Undici integration', () => { it.each([ [ 'simple url', - 'http://localhost:18099', + 'http://localhost:18100', undefined, { - description: 'GET http://localhost:18099/', + description: 'GET http://localhost:18100/', op: 'http.client', data: expect.objectContaining({ 'http.method': 'GET', @@ -63,10 +63,10 @@ conditionalTest({ min: 16 })('Undici integration', () => { ], [ 'url with query', - 'http://localhost:18099?foo=bar', + 'http://localhost:18100?foo=bar', undefined, { - description: 'GET http://localhost:18099/', + description: 'GET http://localhost:18100/', op: 'http.client', data: expect.objectContaining({ 'http.method': 'GET', @@ -76,10 +76,10 @@ conditionalTest({ min: 16 })('Undici integration', () => { ], [ 'url with POST method', - 'http://localhost:18099', + 'http://localhost:18100', { method: 'POST' }, { - description: 'POST http://localhost:18099/', + description: 'POST http://localhost:18100/', data: expect.objectContaining({ 'http.method': 'POST', }), @@ -87,10 +87,10 @@ conditionalTest({ min: 16 })('Undici integration', () => { ], [ 'url with POST method', - 'http://localhost:18099', + 'http://localhost:18100', { method: 'POST' }, { - description: 'POST http://localhost:18099/', + description: 'POST http://localhost:18100/', data: expect.objectContaining({ 'http.method': 'POST', }), @@ -98,10 +98,10 @@ conditionalTest({ min: 16 })('Undici integration', () => { ], [ 'url with GET as default', - 'http://localhost:18099', + 'http://localhost:18100', { method: undefined }, { - description: 'GET http://localhost:18099/', + description: 'GET http://localhost:18100/', }, ], ])('creates a span with a %s', async (_: string, request, requestInit, expected) => { @@ -182,11 +182,11 @@ conditionalTest({ min: 16 })('Undici integration', () => { const undoPatch = patchUndici({ shouldCreateSpanForRequest: url => url.includes('yes') }); - await fetch('http://localhost:18099/no', { method: 'POST' }); + await fetch('http://localhost:18100/no', { method: 'POST' }); expect(transaction.spanRecorder?.spans.length).toBe(1); - await fetch('http://localhost:18099/yes', { method: 'POST' }); + await fetch('http://localhost:18100/yes', { method: 'POST' }); expect(transaction.spanRecorder?.spans.length).toBe(2); @@ -200,7 +200,7 @@ conditionalTest({ min: 16 })('Undici integration', () => { const transaction = hub.startTransaction({ name: 'test-transaction' }) as Transaction; hub.getScope().setSpan(transaction); - await fetch('http://localhost:18099', { method: 'POST' }); + await fetch('http://localhost:18100', { method: 'POST' }); expect(transaction.spanRecorder?.spans.length).toBe(2); const span = transaction.spanRecorder?.spans[1]; @@ -215,7 +215,7 @@ conditionalTest({ min: 16 })('Undici integration', () => { it('attaches the sentry trace and baggage headers if there is no active span', async () => { const scope = hub.getScope(); - await fetch('http://localhost:18099', { method: 'POST' }); + await fetch('http://localhost:18100', { method: 'POST' }); const propagationContext = scope.getPropagationContext(); @@ -234,7 +234,7 @@ conditionalTest({ min: 16 })('Undici integration', () => { const undoPatch = patchUndici({ shouldCreateSpanForRequest: url => url.includes('yes') }); - await fetch('http://localhost:18099/no', { method: 'POST' }); + await fetch('http://localhost:18100/no', { method: 'POST' }); expect(requestHeaders['sentry-trace']).toBeDefined(); expect(requestHeaders['baggage']).toBeDefined(); @@ -242,7 +242,7 @@ conditionalTest({ min: 16 })('Undici integration', () => { expect(requestHeaders['sentry-trace'].includes(propagationContext.traceId)).toBe(true); const firstSpanId = requestHeaders['sentry-trace'].split('-')[1]; - await fetch('http://localhost:18099/yes', { method: 'POST' }); + await fetch('http://localhost:18100/yes', { method: 'POST' }); expect(requestHeaders['sentry-trace']).toBeDefined(); expect(requestHeaders['baggage']).toBeDefined(); @@ -264,14 +264,14 @@ conditionalTest({ min: 16 })('Undici integration', () => { expect(transaction.spanRecorder?.spans.length).toBe(1); - await fetch('http://localhost:18099/no', { method: 'POST' }); + await fetch('http://localhost:18100/no', { method: 'POST' }); expect(transaction.spanRecorder?.spans.length).toBe(2); expect(requestHeaders['sentry-trace']).toBeUndefined(); expect(requestHeaders['baggage']).toBeUndefined(); - await fetch('http://localhost:18099/yes', { method: 'POST' }); + await fetch('http://localhost:18100/yes', { method: 'POST' }); expect(transaction.spanRecorder?.spans.length).toBe(3); @@ -290,7 +290,7 @@ conditionalTest({ min: 16 })('Undici integration', () => { data: { method: 'POST', status_code: 200, - url: 'http://localhost:18099/', + url: 'http://localhost:18100/', }, type: 'http', timestamp: expect.any(Number), @@ -300,7 +300,7 @@ conditionalTest({ min: 16 })('Undici integration', () => { }); hub.bindClient(client); - await fetch('http://localhost:18099', { method: 'POST' }); + await fetch('http://localhost:18100', { method: 'POST' }); }); it('adds a breadcrumb on errored request', async () => { @@ -336,7 +336,7 @@ conditionalTest({ min: 16 })('Undici integration', () => { const undoPatch = patchUndici({ breadcrumbs: false }); - await fetch('http://localhost:18099', { method: 'POST' }); + await fetch('http://localhost:18100', { method: 'POST' }); undoPatch(); }); @@ -382,7 +382,7 @@ function setupTestServer() { res.connection?.end(); }); - testServer?.listen(18099, 'localhost'); + testServer?.listen(18100); return new Promise(resolve => { testServer?.on('listening', resolve);