Skip to content

test: updated promises.test.js re-added the plan() method#6057

Merged
Eomm merged 6 commits intofastify:mainfrom
Tony133:test/migrated-promises-test
May 11, 2025
Merged

test: updated promises.test.js re-added the plan() method#6057
Eomm merged 6 commits intofastify:mainfrom
Tony133:test/migrated-promises-test

Conversation

@Tony133
Copy link
Copy Markdown
Member

@Tony133 Tony133 commented Apr 15, 2025

Checklist

Proposal:

  • update promises.test.js re-added the plan() method 🔥

@Eomm Eomm added the test Issue or pr related to our testing infrastructure. label Apr 16, 2025
@Tony133 Tony133 force-pushed the test/migrated-promises-test branch from f6a8c2b to c588ae8 Compare April 24, 2025 21:09
@Tony133
Copy link
Copy Markdown
Member Author

Tony133 commented Apr 30, 2025

@Eomm as soon as you have time I wanted to ask you, for this PR what do I do, do I close it or do I need to update the PR? you see that the plan() method has been removed, with the latest change, see here: https://github.com/fastify/fastify/pull/6085/files#diff-26e9d5ca961ed63343e75a6e163636828fd423a76eb500c26bb0e169089e1f96L81, it is there in all tests

@jean-michelet
Copy link
Copy Markdown
Member

This is not necessary in these tests, tap.plan behaves differently from what the node test runner does and is often mandatory.
It can still be useful to ensure that the expected number of assertions has been triggered for complex lifecycles, e.g. involving hooks we want to be sure there are executed.

But this is ok to keep them even if there are not very useful, I kept them in other PRs I've done.

@Tony133
Copy link
Copy Markdown
Member Author

Tony133 commented Apr 30, 2025

Personally, I have you keep them on all the tests or take them off on all of them, if you start taking them off in one and in others you leave them, it doesn't make much sense.

Those are rules you have to decide on the tests, so you also keep all the tests in the various repositories in order.

There are in all the tests in the fastify organization repositories. If you follow stable rules, it is also easier for contributors to follow the rules. Think about it

@Tony133 Tony133 changed the title test: migrated promises.test.js from tap to node:test test: updated promises.test.js Apr 30, 2025
@jean-michelet
Copy link
Copy Markdown
Member

This is a pretty old and complex code base with a lot of different contributors on a long period time, there are no such strict rules and nobody want to waste time on it I think.
You can re-add them if you want and ask for a review.

@Tony133
Copy link
Copy Markdown
Member Author

Tony133 commented Apr 30, 2025

I don't think you lose too much time, but just keep things in order, even if the tests are old and complex.

I have updated this PR with the new modifcations so that plan() method is put back in.

@Tony133 Tony133 force-pushed the test/migrated-promises-test branch from 1eba4e4 to 4ecf19b Compare April 30, 2025 15:24
@Tony133 Tony133 changed the title test: updated promises.test.js test: updated promises.test.js re-added the plan() method Apr 30, 2025
@gurgunday gurgunday requested a review from Eomm May 8, 2025 08:13
Copy link
Copy Markdown
Member

@Eomm Eomm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being late, but LGMT

In general the plan helps developer to verify that we are not running more condition than expected. It helped many times catching wrong or missing return statements so I think it is a good practice adding it in general.

In this precise use case, I think the tests were small enough to remove them at that time, but having them is much better for sure!

Thanks

@Eomm Eomm merged commit 0c18914 into fastify:main May 11, 2025
25 checks passed
jean-michelet pushed a commit to jean-michelet/fastify that referenced this pull request May 13, 2025
@Tony133 Tony133 deleted the test/migrated-promises-test branch January 10, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Issue or pr related to our testing infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants