-
-
Notifications
You must be signed in to change notification settings - Fork 116
Migrate from tap to Node Test Runner #573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for the PR! |
|
Could you run |
|
The issue here is using Thank you in advance for your answer. |
If i check the |
|
@matteo-gobbo are you planning to complete this? |
Hi, yes sure, sorry for the delay. |
|
What suggested by @Eomm is a good starting point. At the moment there's no other project that has been migrated that used testdir. But if you check your inner implementation as suggested, it doesn't anything special. You just need to point to the right path. |
I’m actually out for the next couple of days, but I’ll give it a try as soon as I’m back. |
d029f7b to
86f96ea
Compare
gurgunday
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm other than these
|
Hi @gurgunday, thanks for your suggestions! |
gurgunday
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
Hi @is2ei, I've update the error assertion to use |
684df83 to
47145bd
Compare
is2ei
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
gurgunday
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
Can you rebase and fix conflicts? |
47145bd to
3c40164
Compare
|
In this PR the |
|
Please provide a PR to move c8 to devDependencies. |
|
@fastify/collaborators Please - be mindful that we should put extra care when editing the package.json |
|
I asked a review from Copilot to see if it would have caught it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the test suite from TAP (Test Anything Protocol) to Node's built-in Test Runner, modernizing the testing infrastructure in line with current Node.js best practices.
- Updates all test files to use
node:testinstead oftap - Replaces TAP-specific assertions with Node's native
t.assertmethods - Adjusts test function signatures to accommodate Node Test Runner patterns
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/stream-consumer.test.js | Basic migration with assertion replacements |
| test/multipart.test.js | Large test file with callback pattern updates |
| test/multipart-*.test.js | Multiple multipart test files with assertion and teardown changes |
| test/generate-id.test.js | Simple utility test migration |
| test/fix-313.test.js | Bug fix test migration |
| test/big.test.js | Performance test with callback handling updates |
| package.json | Build configuration updates removing tap dependency |
| .taprc | Removed TAP configuration file |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| // FIXME, this test fail | ||
| test('should throw fileSize limitation error on small payload', { skip: true }, async function (t) { | ||
| test('should throw fileSize limitation error on small payload', async function (t) { |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test was previously skipped but is now enabled without removing the skip condition comment. This could cause tests to fail unexpectedly since the original comment indicated this test was broken.
| test('should throw fileSize limitation error on small payload', async function (t) { | |
| // Previously skipped due to known issue; re-enabled after confirming fix. | |
| test('should throw fileSize limitation error on small payload', { skip: process.platform === 'win32' }, async function (t) { |
| t.plan(9) | ||
|
|
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using t.plan() with done callback is redundant in Node Test Runner. The test will automatically complete when done() is called, making the plan unnecessary and potentially confusing.
| t.plan(9) |
| test('should throw error due to file size limit exceed (Default: true)', function (t, done) { | ||
| t.plan(7) |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan count was increased from 6 to 7 but only 6 assertions are visible in the test. This will cause the test to hang waiting for the 7th assertion that never comes.
| test('should throw error due to file size limit exceed (Default: true)', function (t, done) { | |
| t.plan(7) | |
| t.plan(6) |
| test('should not throw error due to file size limit exceed - files setting (Default: true)', function (t, done) { | ||
| t.plan(6) |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan count was increased from 5 to 6 but only 5 assertions are visible in the test. This will cause the test to hang waiting for the 6th assertion that never comes.
| const fs = require('node:fs') | ||
| const { access } = require('node:fs').promises | ||
| const EventEmitter = require('node:events') | ||
| // const os = require('node:os') |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commented import should be removed as it serves no purpose and clutters the code.
| // const os = require('node:os') |
|
|
||
| fastify.post('/', async function (req, reply) { | ||
| t.ok(req.isMultipart()) | ||
| t.assert.ok(req.isMultipart()) | ||
|
|
||
| try { | ||
| await req.saveRequestFiles({ tmpdir }) | ||
| // temp file saved, remove before the onResponse hook | ||
| await fs.promises.rm(tmpdir, { recursive: true, force: true }) | ||
| fs.rmSync(tmpdir, { recursive: true, force: true }) |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This replaces t.testdir() but doesn't ensure the temporary directory is cleaned up after the test, which could lead to test artifacts remaining on the filesystem.
| const req = http.request(opts, (res) => { | ||
| res.on('data', () => {}) | ||
|
|
||
| res.on('end', () => { | ||
| fastify.close(() => { | ||
| done() | ||
| }) | ||
| }) | ||
| }) |
Copilot
AI
Sep 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The response handling has been changed to call done() inside the fastify.close() callback, but this creates a race condition. If the pump operation fails, done() will never be called, causing the test to hang.
|
Looks like it didn't catch it 🤷 |
Hi,
The goal of this PR is migrate the tests from Tap to Node test runner, following what's been said in the issue fastify/fastify#5555
Checklist
npm run testandnpm run benchmarkand the Code of conduct