Skip to content

Commit c56d84d

Browse files
authored
test(node): Fix test runner (#14019)
The changes in #13280 did not pass the error through the `done` callback which means test failures are not detected when using `createTestServer`. Some tests had to be fixed because this change showed that they were in fact failing!
1 parent 8a68fa9 commit c56d84d

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

dev-packages/node-integration-tests/suites/tracing/requests/fetch-breadcrumbs/scenario.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Sentry.init({
77
tracePropagationTargets: [/\/v0/, 'v1'],
88
integrations: [],
99
transport: loggingTransport,
10+
tracesSampleRate: 0.0,
1011
// Ensure this gets a correct hint
1112
beforeBreadcrumb(breadcrumb, hint) {
1213
breadcrumb.data = breadcrumb.data || {};

dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/scenario.ts

+9
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ Sentry.init({
77
tracePropagationTargets: [/\/v0/, 'v1'],
88
integrations: [],
99
transport: loggingTransport,
10+
// Ensure this gets a correct hint
11+
beforeBreadcrumb(breadcrumb, hint) {
12+
breadcrumb.data = breadcrumb.data || {};
13+
const req = hint?.request as { path?: string };
14+
breadcrumb.data.ADDED_PATH = req?.path;
15+
return breadcrumb;
16+
},
1017
});
1118

1219
import * as http from 'http';
1320

1421
async function run(): Promise<void> {
22+
Sentry.addBreadcrumb({ message: 'manual breadcrumb' });
23+
1524
await makeHttpRequest(`${process.env.SERVER_URL}/api/v0`);
1625
await makeHttpGet(`${process.env.SERVER_URL}/api/v1`);
1726
await makeHttpRequest(`${process.env.SERVER_URL}/api/v2`);

dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test('outgoing http requests are correctly instrumented with tracing disabled',
4848
data: {
4949
'http.method': 'GET',
5050
url: `${SERVER_URL}/api/v0`,
51-
status_code: 404,
51+
status_code: 200,
5252
ADDED_PATH: '/api/v0',
5353
},
5454
timestamp: expect.any(Number),
@@ -59,7 +59,7 @@ test('outgoing http requests are correctly instrumented with tracing disabled',
5959
data: {
6060
'http.method': 'GET',
6161
url: `${SERVER_URL}/api/v1`,
62-
status_code: 404,
62+
status_code: 200,
6363
ADDED_PATH: '/api/v1',
6464
},
6565
timestamp: expect.any(Number),
@@ -70,7 +70,7 @@ test('outgoing http requests are correctly instrumented with tracing disabled',
7070
data: {
7171
'http.method': 'GET',
7272
url: `${SERVER_URL}/api/v2`,
73-
status_code: 404,
73+
status_code: 200,
7474
ADDED_PATH: '/api/v2',
7575
},
7676
timestamp: expect.any(Number),
@@ -81,7 +81,7 @@ test('outgoing http requests are correctly instrumented with tracing disabled',
8181
data: {
8282
'http.method': 'GET',
8383
url: `${SERVER_URL}/api/v3`,
84-
status_code: 404,
84+
status_code: 200,
8585
ADDED_PATH: '/api/v3',
8686
},
8787
timestamp: expect.any(Number),

dev-packages/node-integration-tests/utils/server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ export function createTestServer(done: (error?: unknown) => void) {
7070
const address = server.address() as AddressInfo;
7171
resolve([
7272
`http://localhost:${address.port}`,
73-
() => {
73+
(error?: unknown) => {
7474
server.close();
75-
done();
75+
done(error);
7676
},
7777
]);
7878
});

0 commit comments

Comments
 (0)