Skip to content

Commit a28342c

Browse files
authored
chore: Updated integration tests to node:test (#283)
1 parent 7a53a19 commit a28342c

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ module.exports = {
1010
'consistent-return': 'off'
1111
},
1212
parserOptions: {
13-
ecmaVersion: '2020'
13+
ecmaVersion: '2021'
1414
}
1515
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint:fix": "eslint . --fix",
1010
"lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
1111
"unit": "c8 -o ./coverage/unit borp --expose-gc --timeout 180000 'tests/unit/*.test.js'",
12-
"integration": "c8 -o ./coverage/integration tap --timeout 360000 --jobs=1 --no-coverage tests/integration/*.tap.js",
12+
"integration": "c8 -o ./coverage/integration borp --timeout 360000 'tests/integration/*.test.js'",
1313
"native": "node tests/native/*.js",
1414
"test": "npm run unit && npm run integration",
1515
"install": "node-gyp-build",

tests/integration/loop-performance.tap.js renamed to tests/integration/loop-performance.test.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/*
2-
* Copyright 2020 New Relic Corporation. All rights reserved.
2+
* Copyright 2024 New Relic Corporation. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

66
'use strict'
77

8-
const tap = require('tap')
8+
const test = require('node:test')
9+
const assert = require('node:assert')
910

10-
const TEST_DURATION = 30 * 1000
11+
const TEST_DURATION = 30 * 1_000
1112
let performanceThreshold = 0.98
1213
if (process.platform === 'darwin') {
1314
// The GitHub macOS runners are slow and vary widely in their slowness
@@ -17,7 +18,7 @@ if (process.platform === 'darwin') {
1718
performanceThreshold = 0.97
1819
}
1920

20-
tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, function (t) {
21+
test('loop performance test', { timeout: 2 * TEST_DURATION + 1_000 }, (t, end) => {
2122
// The purpose of this test is to measure how much tracking metrics
2223
// impacts the processing overhead of the application loop. To do so, we:
2324
//
@@ -32,13 +33,13 @@ tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, functio
3233
let callCount = 0
3334
let natives = null
3435

35-
t.teardown(function () {
36+
t.after(function () {
3637
if (natives) {
3738
natives.unbind()
3839
}
3940
})
4041

41-
t.comment('measuring without loop counter')
42+
// measuring without loop counter
4243
setTimeoutCount()
4344
setTimeout(function () {
4445
const noMetricsCount = callCount
@@ -48,22 +49,22 @@ tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, functio
4849
natives = require('../../')()
4950
const readInterval = setInterval(function () {
5051
natives.getLoopMetrics() // To reset the metrics
51-
}, 1000)
52+
}, 1_000)
5253

53-
t.comment('measuring with loop counter')
54+
// measuring with loop counter
5455
setTimeoutCount()
5556
setTimeout(function () {
5657
const withMetricsCount = callCount
5758
callCount = 0
5859
clearTimeout(timeout)
5960
clearInterval(readInterval)
6061

61-
t.comment(noMetricsCount + ' vs ' + withMetricsCount)
62-
t.ok(
62+
// console.log(noMetricsCount + ' vs ' + withMetricsCount)
63+
assert.ok(
6364
noMetricsCount * performanceThreshold < withMetricsCount,
6465
`should not impact performance by more than ${1 - performanceThreshold}%`
6566
)
66-
t.end()
67+
end()
6768
}, TEST_DURATION)
6869
}, TEST_DURATION)
6970

0 commit comments

Comments
 (0)