Skip to content

Commit 0ee499b

Browse files
authored
test: Wait for test server to close (#11117)
1 parent 13139d0 commit 0ee499b

File tree

4 files changed

+40
-32
lines changed

4 files changed

+40
-32
lines changed

packages/node-experimental/test/transports/http.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,17 @@ const defaultOptions = {
8080
// empty function to keep test output clean
8181
const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
8282

83-
describe('makeNewHttpTransport()', () => {
84-
afterEach(() => {
85-
jest.clearAllMocks();
86-
87-
if (testServer) {
88-
testServer.close();
89-
}
90-
});
83+
afterEach(done => {
84+
jest.clearAllMocks();
85+
86+
if (testServer && testServer.listening) {
87+
testServer.close(done);
88+
} else {
89+
done();
90+
}
91+
});
9192

93+
describe('makeNewHttpTransport()', () => {
9294
describe('.send()', () => {
9395
it('should correctly send envelope to server', async () => {
9496
await setupTestServer({ statusCode: SUCCESS }, (req, body) => {

packages/node-experimental/test/transports/https.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,17 @@ const defaultOptions = {
8282
recordDroppedEvent: () => undefined, // noop
8383
};
8484

85-
describe('makeNewHttpsTransport()', () => {
86-
afterEach(() => {
87-
jest.clearAllMocks();
88-
89-
if (testServer) {
90-
testServer.close();
91-
}
92-
});
85+
afterEach(done => {
86+
jest.clearAllMocks();
87+
88+
if (testServer && testServer.listening) {
89+
testServer.close(done);
90+
} else {
91+
done();
92+
}
93+
});
9394

95+
describe('makeNewHttpsTransport()', () => {
9496
describe('.send()', () => {
9597
it('should correctly send envelope to server', async () => {
9698
await setupTestServer({ statusCode: SUCCESS }, (req, body) => {

packages/node/test/transports/http.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,17 @@ const defaultOptions = {
8383
// empty function to keep test output clean
8484
const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
8585

86-
describe('makeNewHttpTransport()', () => {
87-
afterEach(() => {
88-
jest.clearAllMocks();
89-
90-
if (testServer) {
91-
testServer.close();
92-
}
93-
});
86+
afterEach(done => {
87+
jest.clearAllMocks();
88+
89+
if (testServer && testServer.listening) {
90+
testServer.close(done);
91+
} else {
92+
done();
93+
}
94+
});
9495

96+
describe('makeNewHttpTransport()', () => {
9597
describe('.send()', () => {
9698
it('should correctly send envelope to server', async () => {
9799
await setupTestServer({ statusCode: SUCCESS }, (req, body) => {

packages/node/test/transports/https.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,17 @@ const defaultOptions = {
8484
recordDroppedEvent: () => undefined, // noop
8585
};
8686

87-
describe('makeNewHttpsTransport()', () => {
88-
afterEach(() => {
89-
jest.clearAllMocks();
90-
91-
if (testServer) {
92-
testServer.close();
93-
}
94-
});
87+
afterEach(done => {
88+
jest.clearAllMocks();
89+
90+
if (testServer && testServer.listening) {
91+
testServer.close(done);
92+
} else {
93+
done();
94+
}
95+
});
9596

97+
describe('makeNewHttpsTransport()', () => {
9698
describe('.send()', () => {
9799
it('should correctly send envelope to server', async () => {
98100
await setupTestServer({ statusCode: SUCCESS }, (req, body) => {

0 commit comments

Comments
 (0)