Skip to content

Commit da38043

Browse files
committed
tests: refactor to prove integration tests w/nock scope fails
The most important changes introduced here is to make sure absolutely *every* nock scope (read: outgoing HTTP request) gets asserted. Previously that was not the case, as only the *first* nock scope was verified, all the other ones has actually not been verified at all. That's what these changes proves; no source code changes has been done, it's only being sure that all nock scopes are actually verified.
1 parent 690a55d commit da38043

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

test/integration/node-labels-webhook.test.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tap.test('Sends POST request to https://api.github.com/repos/nodejs/node/issues/
4444
.reply(200)
4545

4646
t.plan(1)
47-
t.tearDown(() => filesScope.done() && existingRepoLabelsScope.done() && newLabelsScope.done() && clock.uninstall())
47+
t.tearDown(() => clock.uninstall())
4848

4949
supertest(app)
5050
.post('/hooks/github')
@@ -53,6 +53,9 @@ tap.test('Sends POST request to https://api.github.com/repos/nodejs/node/issues/
5353
.expect(200)
5454
.end((err, res) => {
5555
clock.runAll()
56+
filesScope.done()
57+
existingRepoLabelsScope.done()
58+
newLabelsScope.done()
5659
t.equal(err, null)
5760
})
5861
})
@@ -78,7 +81,7 @@ tap.test('Adds v6.x label when PR is targeting the v6.x-staging branch', (t) =>
7881
.reply(200)
7982

8083
t.plan(1)
81-
t.tearDown(() => filesScope.done() && existingRepoLabelsScope.done() && newLabelsScope.done() && clock.uninstall())
84+
t.tearDown(() => clock.uninstall())
8285

8386
supertest(app)
8487
.post('/hooks/github')
@@ -87,6 +90,9 @@ tap.test('Adds v6.x label when PR is targeting the v6.x-staging branch', (t) =>
8790
.expect(200)
8891
.end((err, res) => {
8992
clock.runAll()
93+
filesScope.done()
94+
existingRepoLabelsScope.done()
95+
newLabelsScope.done()
9096
t.equal(err, null)
9197
})
9298
})
@@ -107,7 +113,7 @@ tap.test('Does not create labels which does not already exist', (t) => {
107113
.reply(200, readFixture('repo-labels.json'))
108114

109115
t.plan(1)
110-
t.tearDown(() => filesScope.done() && existingRepoLabelsScope.done() && clock.uninstall())
116+
t.tearDown(() => clock.uninstall())
111117

112118
supertest(app)
113119
.post('/hooks/github')
@@ -116,6 +122,8 @@ tap.test('Does not create labels which does not already exist', (t) => {
116122
.expect(200)
117123
.end((err, res) => {
118124
clock.runAll()
125+
filesScope.done()
126+
existingRepoLabelsScope.done()
119127
t.equal(err, null)
120128
})
121129
})
@@ -142,7 +150,7 @@ tap.test('Adds V8 Engine label when PR has deps/v8 file changes', (t) => {
142150
.reply(200)
143151

144152
t.plan(1)
145-
t.tearDown(() => filesScope.done() && existingRepoLabelsScope.done() && newLabelsScope.done() && clock.uninstall())
153+
t.tearDown(() => clock.uninstall())
146154

147155
supertest(app)
148156
.post('/hooks/github')
@@ -151,6 +159,9 @@ tap.test('Adds V8 Engine label when PR has deps/v8 file changes', (t) => {
151159
.expect(200)
152160
.end((err, res) => {
153161
clock.runAll()
162+
filesScope.done()
163+
existingRepoLabelsScope.done()
164+
newLabelsScope.done()
154165
t.equal(err, null)
155166
})
156167
})

test/integration/trigger-jenkins-build.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tap.test('Sends POST request to https://ci.nodejs.org', (t) => {
4444
.reply(200)
4545

4646
t.plan(1)
47-
t.tearDown(() => collaboratorsScope.done() && ciJobScope.done() && commentScope.done() && clock.uninstall())
47+
t.tearDown(() => clock.uninstall())
4848

4949
supertest(app)
5050
.post('/hooks/github')
@@ -55,6 +55,9 @@ tap.test('Sends POST request to https://ci.nodejs.org', (t) => {
5555
process.env.JENKINS_JOB_URL_NODE = originalJobUrlValue
5656
process.env.JENKINS_BUILD_TOKEN_NODE = originalTokenValue
5757
clock.runAll()
58+
collaboratorsScope.done()
59+
ciJobScope.done()
60+
commentScope.done()
5861
t.equal(err, null)
5962
})
6063
})

0 commit comments

Comments
 (0)