Skip to content

Commit 222d6b3

Browse files
authored
tests: Test with node v17 (#107)
Also bump to tap@15 (min supported node is v10). tap@14 doesn't work with node v16 and later (tapjs/tapjs#746).
1 parent 31b3924 commit 222d6b3

File tree

14 files changed

+64
-57
lines changed

14 files changed

+64
-57
lines changed

.ci/Jenkinsfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ pipeline {
6262
buildWithGitHubNotification('16')
6363
}
6464
}
65+
stage('Test - Node.js v17') {
66+
agent { label 'linux && immutable' }
67+
options { skipDefaultCheckout() }
68+
steps {
69+
buildWithGitHubNotification('17')
70+
}
71+
}
6572
}
6673
}
6774
}

helpers/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"homepage": "https://github.com/elastic/ecs-logging-nodejs/blob/master/helpers/README.md",
1919
"scripts": {
20-
"test": "standard && tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
20+
"test": "standard && tap --no-check-coverage --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
2121
},
2222
"engines": {
2323
"node": ">=10"
@@ -32,6 +32,6 @@
3232
"express": "^4.17.1",
3333
"semver": "^7.1.3",
3434
"standard": "16.x",
35-
"tap": "^14.x"
35+
"tap": "^15.0.10"
3636
}
3737
}

helpers/test/basic.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ test('formatHttpRequest and formatHttpResponse should return a valid ecs object'
154154
t.ok(validate(line))
155155
t.equal(ecsLoggingValidate(line), null)
156156

157-
t.deepEqual(line.user_agent, { original: 'cool-agent' })
158-
t.deepEqual(line.url, {
157+
t.same(line.user_agent, { original: 'cool-agent' })
158+
t.same(line.url, {
159159
path: '/hello/world',
160160
query: 'foo=bar',
161161
full: `http://localhost:${server.address().port}/hello/world?foo=bar#anchor`,
162162
fragment: 'anchor'
163163
})
164-
t.deepEqual(line.http, {
164+
t.same(line.http, {
165165
version: '1.1',
166166
request: {
167167
method: 'POST',
@@ -208,18 +208,18 @@ test('format* should not process non-req/res/err values', t => {
208208
inputs.forEach(input => {
209209
obj = {}
210210
rv = formatError(obj, input)
211-
t.strictEqual(rv, false, `formatError did not process input: ${inspect(input)}`)
211+
t.equal(rv, false, `formatError did not process input: ${inspect(input)}`)
212212
// Cannot test that obj is unmodified because `formatError` sets obj.err.
213213
// See https://github.com/elastic/ecs-logging-nodejs/issues/66 to change that.
214214

215215
obj = {}
216216
rv = formatHttpRequest(obj, input)
217-
t.strictEqual(rv, false, `formatHttpRequest did not process input: ${inspect(input)}`)
217+
t.equal(rv, false, `formatHttpRequest did not process input: ${inspect(input)}`)
218218
t.equal(Object.keys(obj).length, 0, `obj was not modified: ${inspect(obj)}`)
219219

220220
obj = {}
221221
rv = formatHttpResponse(obj, input)
222-
t.strictEqual(rv, false, `formatHttpResponse did not process input: ${inspect(input)}`)
222+
t.equal(rv, false, `formatHttpResponse did not process input: ${inspect(input)}`)
223223
t.equal(Object.keys(obj).length, 0, `obj was not modified: ${inspect(obj)}`)
224224
})
225225
t.end()
@@ -246,9 +246,9 @@ test('stringify should emit valid tracing fields', t => {
246246
const after = JSON.parse(stringify(before))
247247
t.ok(validate(after))
248248
t.equal(ecsLoggingValidate(after), null)
249-
t.deepEqual(after.trace, { id: '1' }, 'trace.id is stringified')
250-
t.deepEqual(after.transaction, { id: '2' }, 'transaction.id is stringified')
251-
t.deepEqual(after.span, { id: '3' },
249+
t.same(after.trace, { id: '1' }, 'trace.id is stringified')
250+
t.same(after.transaction, { id: '2' }, 'transaction.id is stringified')
251+
t.same(after.span, { id: '3' },
252252
'span.id is stringified, extra fields are excluded')
253253
t.end()
254254
})

helpers/test/express.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ test('express res/req serialization', t => {
4343
rv = formatHttpResponse(rec, res)
4444
t.ok(rv, 'formatHttpResponse processed res')
4545

46-
t.deepEqual(rec.user_agent, { original: 'cool-agent' })
47-
t.deepEqual(rec.url, {
46+
t.same(rec.user_agent, { original: 'cool-agent' })
47+
t.same(rec.url, {
4848
path: '/',
4949
full: `http://localhost:${server.address().port}/`,
5050
domain: 'localhost'
5151
})
52-
t.deepEqual(rec.http, {
52+
t.same(rec.http, {
5353
version: '1.1',
5454
request: {
5555
method: 'GET',

helpers/test/hapi.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ test('hapi res/req serialization', testOpts, t => {
5353
rv = formatHttpResponse(rec, request)
5454
t.ok(rv, 'formatHttpResponse processed request')
5555

56-
t.deepEqual(rec.user_agent, { original: 'cool-agent' })
57-
t.deepEqual(rec.url, {
56+
t.same(rec.user_agent, { original: 'cool-agent' })
57+
t.same(rec.url, {
5858
path: '/',
5959
full: `http://localhost:${server.info.port}/`
6060
})
61-
t.deepEqual(rec.http, {
61+
t.same(rec.http, {
6262
version: '1.1',
6363
request: {
6464
method: 'GET',

loggers/morgan/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"homepage": "https://github.com/elastic/ecs-logging-nodejs/blob/master/loggers/morgan/README.md",
3131
"scripts": {
32-
"test": "standard && tap --100 --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
32+
"test": "standard && tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
3333
},
3434
"engines": {
3535
"node": ">=10"
@@ -45,6 +45,6 @@
4545
"morgan": "^1.9.1",
4646
"split2": "^3.1.1",
4747
"standard": "16.x",
48-
"tap": "^14.x"
48+
"tap": "^15.0.10"
4949
}
5050
}

loggers/morgan/test/apm.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,23 @@ test('tracing integration works', t => {
155155
}
156156

157157
step1StartMockApmServer(function onListening (apmServerErr, apmServerUrl) {
158-
t.ifErr(apmServerErr)
158+
t.error(apmServerErr)
159159
if (apmServerErr) {
160160
finish()
161161
return
162162
}
163163
t.ok(apmServerUrl, 'apmServerUrl: ' + apmServerUrl)
164164

165165
step2StartApp(apmServerUrl, function onReady (appErr, appUrl) {
166-
t.ifErr(appErr)
166+
t.error(appErr)
167167
if (appErr) {
168168
finish()
169169
return
170170
}
171171
t.ok(appUrl, 'appUrl: ' + appUrl)
172172

173173
step3CallApp(appUrl, function (clientErr) {
174-
t.ifErr(clientErr)
174+
t.error(clientErr)
175175

176176
// The thread of control now is expected to be in
177177
// `collectTracesLogsAndCheck()`.
@@ -300,23 +300,23 @@ test('apmIntegration=false disables tracing integration', t => {
300300
}
301301

302302
step1StartMockApmServer(function onListening (apmServerErr, apmServerUrl) {
303-
t.ifErr(apmServerErr)
303+
t.error(apmServerErr)
304304
if (apmServerErr) {
305305
finish()
306306
return
307307
}
308308
t.ok(apmServerUrl, 'apmServerUrl: ' + apmServerUrl)
309309

310310
step2StartApp(apmServerUrl, function onReady (appErr, appUrl) {
311-
t.ifErr(appErr)
311+
t.error(appErr)
312312
if (appErr) {
313313
finish()
314314
return
315315
}
316316
t.ok(appUrl, 'appUrl: ' + appUrl)
317317

318318
step3CallApp(appUrl, function (clientErr) {
319-
t.ifErr(clientErr)
319+
t.error(clientErr)
320320

321321
// The thread of control now is expected to be in
322322
// `collectTracesLogsAndCheck()`.

loggers/morgan/test/basic.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ test('Should produce valid ecs logs', t => {
7474

7575
const stream = split().on('data', line => {
7676
const rec = JSON.parse(line)
77-
t.true(validate(rec))
77+
t.ok(validate(rec))
7878
t.equal(ecsLoggingValidate(line), null)
7979
})
8080
const logger = morgan(ecsFormat(), { stream })
8181

8282
makeExpressServerAndRequest(logger, '/?foo=bar', { method: 'POST' }, 'hi', function (err) {
83-
t.ifErr(err)
83+
t.error(err)
8484
t.end()
8585
})
8686
})
@@ -97,7 +97,7 @@ test('Keys order', t => {
9797
const logger = morgan(ecsFormat(), { stream })
9898

9999
makeExpressServerAndRequest(logger, '/?foo=bar', { method: 'POST' }, 'hi', function (err) {
100-
t.ifErr(err)
100+
t.error(err)
101101
t.end()
102102
})
103103
})
@@ -116,7 +116,7 @@ test('"format" argument - format name', t => {
116116
const logger = morgan(ecsFormat(format), { stream })
117117

118118
makeExpressServerAndRequest(logger, '/?foo=bar', { method: 'POST' }, 'hi', function (err) {
119-
t.ifErr(err)
119+
t.error(err)
120120
t.end()
121121
})
122122
})
@@ -135,7 +135,7 @@ test('"format" argument - format string', t => {
135135
const logger = morgan(ecsFormat(format), { stream })
136136

137137
makeExpressServerAndRequest(logger, '/?foo=bar', { method: 'POST' }, 'hi', function (err) {
138-
t.ifErr(err)
138+
t.error(err)
139139
t.end()
140140
})
141141
})
@@ -154,7 +154,7 @@ test('"format" argument - format function', t => {
154154
const logger = morgan(ecsFormat(format), { stream })
155155

156156
makeExpressServerAndRequest(logger, '/?foo=bar', { method: 'POST' }, 'hi', function (err) {
157-
t.ifErr(err)
157+
t.error(err)
158158
t.end()
159159
})
160160
})
@@ -173,7 +173,7 @@ test('"opts.format" argument', t => {
173173
const logger = morgan(ecsFormat({ format: format }), { stream })
174174

175175
makeExpressServerAndRequest(logger, '/?foo=bar', { method: 'POST' }, 'hi', function (err) {
176-
t.ifErr(err)
176+
t.error(err)
177177
t.end()
178178
})
179179
})
@@ -188,7 +188,7 @@ test('"log.level" for successful response is "info"', t => {
188188
const logger = morgan(ecsFormat(), { stream })
189189

190190
makeExpressServerAndRequest(logger, '/', {}, null, function (err) {
191-
t.ifErr(err)
191+
t.error(err)
192192
t.end()
193193
})
194194
})
@@ -203,7 +203,7 @@ test('"log.level" for failing response is "error"', t => {
203203
const logger = morgan(ecsFormat(), { stream })
204204

205205
makeExpressServerAndRequest(logger, '/error', {}, null, function (err) {
206-
t.ifErr(err)
206+
t.error(err)
207207
t.end()
208208
})
209209
})

loggers/pino/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"homepage": "https://github.com/elastic/ecs-logging-nodejs/blob/master/loggers/pino/README.md",
3232
"scripts": {
33-
"test": "standard && tap --100 --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
33+
"test": "standard && tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js"
3434
},
3535
"engines": {
3636
"node": ">=10"
@@ -48,6 +48,6 @@
4848
"pino-http": "^5.3.0",
4949
"split2": "^3.1.1",
5050
"standard": "16.x",
51-
"tap": "^14.x"
51+
"tap": "^15.0.10"
5252
}
5353
}

loggers/pino/test/apm.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,23 +298,23 @@ test('apmIntegration=false disables tracing integration', t => {
298298
}
299299

300300
step1StartMockApmServer(function onListening (apmServerErr, apmServerUrl) {
301-
t.ifErr(apmServerErr)
301+
t.error(apmServerErr)
302302
if (apmServerErr) {
303303
finish()
304304
return
305305
}
306306
t.ok(apmServerUrl, 'apmServerUrl: ' + apmServerUrl)
307307

308308
step2StartApp(apmServerUrl, function onReady (appErr, appUrl) {
309-
t.ifErr(appErr)
309+
t.error(appErr)
310310
if (appErr) {
311311
finish()
312312
return
313313
}
314314
t.ok(appUrl, 'appUrl: ' + appUrl)
315315

316316
step3CallApp(appUrl, function (clientErr) {
317-
t.ifErr(clientErr)
317+
t.error(clientErr)
318318

319319
// The thread of control now is expected to be in
320320
// `collectTracesLogsAndCheck()`.
@@ -330,7 +330,7 @@ test('can override service.name, event.dataset', t => {
330330
], {
331331
timeout: 5000
332332
}, function (err, stdout, stderr) {
333-
t.ifErr(err)
333+
t.error(err)
334334
const recs = stdout.trim().split(/\n/g).map(JSON.parse)
335335
t.equal(recs[0].service.name, 'myname')
336336
t.equal(recs[0].event.dataset, 'mydataset')
@@ -357,7 +357,7 @@ test('can override service.name, event.dataset in base arg to constructor', t =>
357357
], {
358358
timeout: 5000
359359
}, function (err, stdout, stderr) {
360-
t.ifErr(err)
360+
t.error(err)
361361
const recs = stdout.trim().split(/\n/g).map(JSON.parse)
362362
t.equal(recs[0].service.name, 'myname')
363363
t.equal(recs[0].event.dataset, 'mydataset')
@@ -378,7 +378,7 @@ test('unset APM serviceName does not set service.name, event.dataset, but also d
378378
// up dirs for a package.json, does *not* work by execing from the root dir.
379379
cwd: '/'
380380
}, function (err, stdout, stderr) {
381-
t.ifErr(err)
381+
t.error(err)
382382
const recs = stdout.trim().split(/\n/g).map(JSON.parse)
383383
t.equal(recs[0].service.name, 'myname')
384384
t.equal(recs[0].event.dataset, 'mydataset')

0 commit comments

Comments
 (0)