Skip to content

Commit 9063215

Browse files
authored
chore: replace tap by node:test (#1042)
This PR replaces Tap by node:test Tasks: - [x] auth.js - [x] basic.js - [x] bridge.js - [x] client-pub-sub.js - [x] close_socket_by_other_party.js - [x] connect.js (with TODO's) - [x] events.js - [x] keep-alive.js - [x] meta.js (with 1 TODO) - [x] not-blocking.js - [x] qos1.js - [x] qos2.js - [x] regr-21.js - [x] require.cjs - [x] retain.js (with 1 TODO) - [x] topics.js - [x] will.js - [x] update package.json scripts - [x] update package.json devDependencies - [x] update 'coverage' directory in ci.yml The following devDependencies have been replaced by NodeJS native functionality - @sinonjs/fake-timers - concat-stream - duplexify - mqtt-connection - tap It adds `c8` as devDependency to facilitate test coverage.
1 parent b5178c0 commit 9063215

21 files changed

+5898
-6546
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
if: strategy.job-index == 0
6666
uses: codecov/codecov-action@v5
6767
with:
68-
directory: .tap/report
68+
directory: coverage
6969
fail_ci_if_error: true
7070
flags: unittests
7171
name: codecov-aedes

checkVersion.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// node 20 on windows has issues with node:test wildcard
2+
// this script is only used by package.json
3+
// example of usage in package.json:
4+
// "unit": "node checkVersion.js && npm run unit:v20win32 || npm run unit:other",
5+
// "unit:v20win32": "node --test --test-timeout=180000",
6+
// "unit:other": "node --test --test-timeout=180000 test/*.js test/*.cjs",
7+
8+
/* c8 ignore start */
9+
import { platform, version, exit } from 'node:process'
10+
11+
const major = version.split('.')[0]
12+
let exitCode = 1
13+
// node 20 on windows returns 0
14+
if ((major === 'v20') && platform === 'win32') {
15+
exitCode = 0
16+
}
17+
// all the others 1
18+
console.log(`Running ${major} on ${platform} returning exitCode ${exitCode}`)
19+
exit(exitCode)
20+
/* c8 ignore stop */

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
"lint:markdown": "markdownlint docs/*.md README.md",
1313
"lint:markdown:fix": "markdownlint --fix docs/*.md README.md",
1414
"test": "npm run lint && npm run unit && npm run test:typescript",
15-
"test:ci": "npm run lint && npm run unit:coverage && npm run test:typescript",
15+
"test:ci": "npm run lint && npm run coverage && npm run test:typescript",
1616
"test:report": "npm run lint && npm run unit:report && npm run test:typescript",
1717
"test:typescript": "tsd",
18-
"unit": "tap test/*.js",
19-
"unit:coverage": "tap --coverage-report=lcov test/*.js",
18+
"unit": "node checkVersion.js && npm run unit:v20win32 || npm run unit:other",
19+
"unit:v20win32": "node --test --test-timeout=180000",
20+
"unit:other": "node --test --test-timeout=180000 test/*.js test/*.cjs",
21+
"coverage": "c8 --reporter=lcov npm run unit",
22+
"coverage:report": "c8 report",
2023
"license-checker": "license-checker --production --onlyAllow=\"MIT;ISC;BSD-3-Clause;BSD-2-Clause;0BSD\"",
2124
"release": "read -p 'GITHUB_TOKEN: ' GITHUB_TOKEN && export GITHUB_TOKEN=$GITHUB_TOKEN && release-it --disable-metrics"
2225
},
@@ -103,19 +106,15 @@
103106
},
104107
"devDependencies": {
105108
"@fastify/pre-commit": "^2.2.0",
106-
"@sinonjs/fake-timers": "^14.0.0",
107-
"@types/node": "^24.0.14",
108-
"concat-stream": "^2.0.0",
109-
"duplexify": "^4.1.3",
110-
"eslint": "^9.31.0",
109+
"@types/node": "^24.2.0",
110+
"c8": "^10.1.3",
111+
"eslint": "^9.32.0",
111112
"license-checker": "^25.0.1",
112113
"markdownlint-cli": "^0.45.0",
113-
"mqtt": "^5.13.2",
114-
"mqtt-connection": "^4.1.0",
114+
"mqtt": "^5.14.0",
115115
"neostandard": "^0.12.2",
116-
"release-it": "^19.0.3",
117-
"tap": "^21.1.0",
118-
"tsd": "^0.32.0",
116+
"release-it": "^19.0.4",
117+
"tsd": "^0.33.0",
119118
"ws": "^8.18.3"
120119
},
121120
"dependencies": {
@@ -133,6 +132,7 @@
133132
"uuid": "^11.1.0"
134133
},
135134
"peerDependencies": {
135+
"aedes-persistence-level": "^9.1.2",
136136
"aedes-persistence-mongodb": "^9.3.1",
137137
"aedes-persistence-redis": "^11.2.1"
138138
},

0 commit comments

Comments
 (0)