Skip to content

Commit 4b270ff

Browse files
authored
chore: move from tap to Node.js test runner (#594)
This eliminates a (bogus) security warning about a tap dependency.
1 parent f10ad1a commit 4b270ff

9 files changed

+271
-4307
lines changed

package-lock.json

+146-4,185
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"start": "node server.js | bunyan -o short",
8-
"test": "STATUS=0; tap --allow-incomplete-coverage test/**/*.test.js || STATUS=$?; standard || STATUS=$?; exit $STATUS",
8+
"test": "STATUS=0; node --test test/**/*.test.js || STATUS=$?; standard || STATUS=$?; exit $STATUS",
99
"test:watch": "nodemon -q -x 'npm test'"
1010
},
1111
"engines": {
@@ -33,7 +33,6 @@
3333
"nock": "^14.0.1",
3434
"nodemon": "^3.1.9",
3535
"standard": "^17.1.2",
36-
"supertest": "^7.0.0",
37-
"tap": "^21.1.0"
36+
"supertest": "^7.0.0"
3837
}
3938
}

test/integration/event-relay-to-github-actions.test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import tap from 'tap'
1+
import test from 'node:test'
22
import fetchMock from 'fetch-mock'
33
import supertest from 'supertest'
44

@@ -10,7 +10,7 @@ import eventRelay from '../../scripts/event-relay.js'
1010

1111
eventRelay(app, events)
1212

13-
tap.test('Sends POST requests to https://api.github.com/repos/nodejs/<repo>/dispatches', (t) => {
13+
test('Sends POST requests to https://api.github.com/repos/nodejs/<repo>/dispatches', (t, done) => {
1414
const jenkinsPayload = readFixture('success-payload.json')
1515

1616
fetchMock.mockGlobal()
@@ -23,7 +23,8 @@ tap.test('Sends POST requests to https://api.github.com/repos/nodejs/<repo>/disp
2323
.send(jenkinsPayload)
2424
.expect(200)
2525
.end((err, res) => {
26-
t.equal(err, null)
27-
t.equal(fetchMock.callHistory.called(), true)
26+
t.assert.strictEqual(err, null)
27+
t.assert.strictEqual(fetchMock.callHistory.called(), true)
28+
done()
2829
})
2930
})

test/integration/ping.test.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
import http from 'node:http'
22

3-
import tap from 'tap'
3+
import test from 'node:test'
44

55
import { app, events } from '../../app.js'
66

77
import ping from '../../scripts/ping.js'
88

99
ping(app, events)
1010

11-
tap.test('GET /ping responds with status 200 / "pong"', (t) => {
11+
test('GET /ping responds with status 200 / "pong"', (t, done) => {
1212
const server = app.listen()
1313
const port = server.address().port
1414
const url = `http://localhost:${port}/ping`
1515

1616
t.plan(2)
17-
t.teardown(() => server.close())
17+
t.after(() => server.close())
1818

1919
http.get(url, (res) => {
20-
t.equal(res.statusCode, 200)
20+
t.assert.strictEqual(res.statusCode, 200)
2121

2222
let data = ''
2323
res.on('data', (chunk) => {
2424
data += chunk
2525
})
2626
res.on('end', () => {
27-
t.equal(data, 'pong')
27+
t.assert.strictEqual(data, 'pong')
28+
done()
2829
})
2930
}).on('error', (e) => {
3031
t.fail(e)

test/integration/push-jenkins-update.test.js

+41-31
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import tap from 'tap'
1+
import test from 'node:test'
22
import fetchMock from 'fetch-mock'
33
import supertest from 'supertest'
44

@@ -13,7 +13,7 @@ fetchMock.mockGlobal()
1313

1414
jenkinsStatus(app, events)
1515

16-
tap.test('Sends POST requests to https://api.github.com/repos/nodejs/node/statuses/<SHA>', (t) => {
16+
test('Sends POST requests to https://api.github.com/repos/nodejs/node/statuses/<SHA>', (t, done) => {
1717
const jenkinsPayload = readFixture('success-payload.json')
1818

1919
const listCommitsUrl = setupListCommitsMock('node')
@@ -28,13 +28,14 @@ tap.test('Sends POST requests to https://api.github.com/repos/nodejs/node/status
2828
.send(jenkinsPayload)
2929
.expect(200)
3030
.end((err, res) => {
31-
t.equal(err, null)
32-
t.equal(fetchMock.callHistory.called(url), true)
33-
t.equal(fetchMock.callHistory.called(listCommitsUrl), true)
31+
t.assert.strictEqual(err, null)
32+
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
33+
t.assert.strictEqual(fetchMock.callHistory.called(listCommitsUrl), true)
34+
done()
3435
})
3536
})
3637

37-
tap.test('Allows repository name to be provided with URL parameter when pushing job started', (t) => {
38+
test('Allows repository name to be provided with URL parameter when pushing job started', (t, done) => {
3839
const jenkinsPayload = readFixture('pending-payload.json')
3940

4041
const listCommitsUrl = setupListCommitsMock('citgm')
@@ -49,13 +50,14 @@ tap.test('Allows repository name to be provided with URL parameter when pushing
4950
.send(jenkinsPayload)
5051
.expect(200)
5152
.end((err, res) => {
52-
t.equal(err, null)
53-
t.equal(fetchMock.callHistory.called(url), true)
54-
t.equal(fetchMock.callHistory.called(listCommitsUrl), true)
53+
t.assert.strictEqual(err, null)
54+
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
55+
t.assert.strictEqual(fetchMock.callHistory.called(listCommitsUrl), true)
56+
done()
5557
})
5658
})
5759

58-
tap.test('Allows repository name to be provided with URL parameter when pushing job ended', (t) => {
60+
test('Allows repository name to be provided with URL parameter when pushing job ended', (t, done) => {
5961
const jenkinsPayload = readFixture('success-payload.json')
6062

6163
const listCommitsUrl = setupListCommitsMock('citgm')
@@ -70,13 +72,14 @@ tap.test('Allows repository name to be provided with URL parameter when pushing
7072
.send(jenkinsPayload)
7173
.expect(200)
7274
.end((err, res) => {
73-
t.equal(err, null)
74-
t.equal(fetchMock.callHistory.called(url), true)
75-
t.equal(fetchMock.callHistory.called(listCommitsUrl), true)
75+
t.assert.strictEqual(err, null)
76+
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
77+
t.assert.strictEqual(fetchMock.callHistory.called(listCommitsUrl), true)
78+
done()
7679
})
7780
})
7881

79-
tap.test('Forwards payload provided in incoming POST to GitHub status API', (t) => {
82+
test('Forwards payload provided in incoming POST to GitHub status API', (t, done) => {
8083
const fixture = readFixture('success-payload.json')
8184

8285
const listCommitsUrl = setupListCommitsMock('node')
@@ -97,13 +100,14 @@ tap.test('Forwards payload provided in incoming POST to GitHub status API', (t)
97100
.send(fixture)
98101
.expect(200)
99102
.end((err, res) => {
100-
t.equal(err, null)
101-
t.equal(fetchMock.callHistory.called(url), true)
102-
t.equal(fetchMock.callHistory.called(listCommitsUrl), true)
103+
t.assert.strictEqual(err, null)
104+
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
105+
t.assert.strictEqual(fetchMock.callHistory.called(listCommitsUrl), true)
106+
done()
103107
})
104108
})
105109

106-
tap.test('Posts a CI comment in the related PR when Jenkins build is named node-test-pull-request', (t) => {
110+
test('Posts a CI comment in the related PR when Jenkins build is named node-test-pull-request', (t, done) => {
107111
const fixture = readFixture('jenkins-test-pull-request-success-payload.json')
108112

109113
const url = 'https://api.github.com/repos/nodejs/node/issues/12345/comments'
@@ -125,12 +129,13 @@ tap.test('Posts a CI comment in the related PR when Jenkins build is named node-
125129
.send(fixture)
126130
.expect(200)
127131
.end((err, res) => {
128-
t.equal(fetchMock.callHistory.called(url), true)
129-
t.equal(err, null)
132+
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
133+
t.assert.strictEqual(err, null)
134+
done()
130135
})
131136
})
132137

133-
tap.test('Posts a CI comment in the related PR when Jenkins build is named node-test-pull-request-lite-pipeline', (t) => {
138+
test('Posts a CI comment in the related PR when Jenkins build is named node-test-pull-request-lite-pipeline', (t, done) => {
134139
const fixture = readFixture('jenkins-test-pull-request-success-payload.json')
135140
fixture.identifier = 'node-test-pull-request-lite-pipeline'
136141

@@ -153,12 +158,13 @@ tap.test('Posts a CI comment in the related PR when Jenkins build is named node-
153158
.send(fixture)
154159
.expect(200)
155160
.end((err, res) => {
156-
t.equal(fetchMock.callHistory.called(url), true)
157-
t.equal(err, null)
161+
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
162+
t.assert.strictEqual(err, null)
163+
done()
158164
})
159165
})
160166

161-
tap.test('Responds with 400 / "Bad request" when incoming request has invalid payload', (t) => {
167+
test('Responds with 400 / "Bad request" when incoming request has invalid payload', (t, done) => {
162168
const fixture = readFixture('invalid-payload.json')
163169

164170
// don't care about the results, just want to prevent any HTTP request ever being made
@@ -171,11 +177,12 @@ tap.test('Responds with 400 / "Bad request" when incoming request has invalid pa
171177
.send(fixture)
172178
.expect(400, 'Invalid payload')
173179
.end((err, res) => {
174-
t.equal(err, null)
180+
t.assert.strictEqual(err, null)
181+
done()
175182
})
176183
})
177184

178-
tap.test('Responds with 400 / "Bad request" when build started status update is not related to a pull request', (t) => {
185+
test('Responds with 400 / "Bad request" when build started status update is not related to a pull request', (t, done) => {
179186
const fixture = readFixture('jenkins-staging-failure-payload.json')
180187

181188
// don't care about the results, just want to prevent any HTTP request ever being made
@@ -188,11 +195,12 @@ tap.test('Responds with 400 / "Bad request" when build started status update is
188195
.send(fixture)
189196
.expect(400, 'Will only push builds related to pull requests')
190197
.end((err, res) => {
191-
t.equal(err, null)
198+
t.assert.strictEqual(err, null)
199+
done()
192200
})
193201
})
194202

195-
tap.test('Responds with 400 / "Bad request" when build ended status update is not related to a pull request', (t) => {
203+
test('Responds with 400 / "Bad request" when build ended status update is not related to a pull request', (t, done) => {
196204
const fixture = readFixture('jenkins-staging-failure-payload.json')
197205

198206
// don't care about the results, just want to prevent any HTTP request ever being made
@@ -205,11 +213,12 @@ tap.test('Responds with 400 / "Bad request" when build ended status update is no
205213
.send(fixture)
206214
.expect(400, 'Will only push builds related to pull requests')
207215
.end((err, res) => {
208-
t.equal(err, null)
216+
t.assert.strictEqual(err, null)
217+
done()
209218
})
210219
})
211220

212-
tap.test('Responds with 400 / "Bad request" when incoming providing invalid repository name', (t) => {
221+
test('Responds with 400 / "Bad request" when incoming providing invalid repository name', (t, done) => {
213222
const fixture = readFixture('pending-payload.json')
214223

215224
// don't care about the results, just want to prevent any HTTP request ever being made
@@ -222,7 +231,8 @@ tap.test('Responds with 400 / "Bad request" when incoming providing invalid repo
222231
.send(fixture)
223232
.expect(400, 'Invalid repository')
224233
.end((err, res) => {
225-
t.equal(err, null)
234+
t.assert.strictEqual(err, null)
235+
done()
226236
})
227237
})
228238

test/unit/node-owners.test.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1-
import tap from 'tap'
1+
import test from 'node:test'
22

33
import { Owners } from '../../lib/node-owners.js'
44
import readFixture from '../read-fixture.js'
55

66
const ownersFile = readFixture('CODEOWNERS')
77

8-
tap.test('single file single team match', (t) => {
8+
test('single file single team match', (t, done) => {
99
const owners = Owners.fromFile(ownersFile)
10-
t.strictSame(
10+
t.assert.deepStrictEqual(
1111
owners.getOwnersForPaths(['file1']),
1212
['@nodejs/test1']
1313
)
14-
t.end()
14+
done()
1515
})
1616

17-
tap.test('double file single team match', (t) => {
17+
test('double file single team match', (t, done) => {
1818
const owners = Owners.fromFile(ownersFile)
19-
t.strictSame(
19+
t.assert.deepStrictEqual(
2020
owners.getOwnersForPaths(['file1', 'file4']),
2121
['@nodejs/test1']
2222
)
23-
t.end()
23+
done()
2424
})
2525

26-
tap.test('double file double individual team match', (t) => {
26+
test('double file double individual team match', (t, done) => {
2727
const owners = Owners.fromFile(ownersFile)
28-
t.strictSame(
28+
t.assert.deepStrictEqual(
2929
owners.getOwnersForPaths(['file1', 'file2']),
3030
['@nodejs/test1', '@nodejs/test2']
3131
)
32-
t.end()
32+
done()
3333
})
3434

35-
tap.test('single file double team match', (t) => {
35+
test('single file double team match', (t, done) => {
3636
const owners = Owners.fromFile(ownersFile)
37-
t.strictSame(
37+
t.assert.deepStrictEqual(
3838
owners.getOwnersForPaths(['file3']),
3939
['@nodejs/test1', '@nodejs/test2']
4040
)
41-
t.end()
41+
done()
4242
})
4343

44-
tap.test('double file triple team match (1 + 2)', (t) => {
44+
test('double file triple team match (1 + 2)', (t, done) => {
4545
const owners = Owners.fromFile(ownersFile)
46-
t.strictSame(
46+
t.assert.deepStrictEqual(
4747
owners.getOwnersForPaths(['file5', 'file3']),
4848
['@nodejs/test1', '@nodejs/test2', '@nodejs/test3']
4949
)
50-
t.end()
50+
done()
5151
})
5252

53-
tap.test('folder match', (t) => {
53+
test('folder match', (t, done) => {
5454
const owners = Owners.fromFile(ownersFile)
55-
t.strictSame(
55+
t.assert.deepStrictEqual(
5656
owners.getOwnersForPaths(['folder1/file5']),
5757
['@nodejs/test3']
5858
)
59-
t.end()
59+
done()
6060
})
6161

62-
tap.test('extension match', (t) => {
62+
test('extension match', (t, done) => {
6363
const owners = Owners.fromFile(ownersFile)
64-
t.strictSame(
64+
t.assert.deepStrictEqual(
6565
owners.getOwnersForPaths(['folder2/file1.js']),
6666
['@nodejs/test4', '@nodejs/test5']
6767
)
68-
t.end()
68+
done()
6969
})
7070

71-
tap.test('no match', (t) => {
71+
test('no match', (t, done) => {
7272
const owners = Owners.fromFile(ownersFile)
73-
t.strictSame(
73+
t.assert.deepStrictEqual(
7474
owners.getOwnersForPaths(['unknown']),
7575
[]
7676
)
77-
t.end()
77+
done()
7878
})
7979

80-
tap.test('no match + single match', (t) => {
80+
test('no match + single match', (t, done) => {
8181
const owners = Owners.fromFile(ownersFile)
82-
t.strictSame(
82+
t.assert.deepStrictEqual(
8383
owners.getOwnersForPaths(['unknown', 'file1']),
8484
['@nodejs/test1']
8585
)
86-
t.end()
86+
done()
8787
})

0 commit comments

Comments
 (0)