refactor(test): replaces mocha with node:test #827
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This won't be merged
Everything works. Had to write a little test reporter to get output that is to the point (no thousands of tests over the screen, but just a little bit of progress information and only full information if a test fails).
However, this PR is not going to be merged. I will continue to work with node:test projects that have (far) less automated tests as having no external dependencies for tests is still pretty neat. For dependency-cruiser, at this time, the drawbacks are heavier than the benefits.
Why this is not going to be merged 1/2: node:test is too slow
There's a big drawback on using node:test on this amount of tests, though - node:test is very CPU hungry and twice as slow as exactly the same tests run with
mocha
. This is not a problem when there's a moderate number of tests, but with ~1400 of them it really adds up.The unix
time
utility emits numbers like this for node:test on my local machine:With mocha the same run looks like this:
On the ci the slowdowns are comparable - see the ci runs associated with this PR.
Why this is not going to be merged 2/2: challenges in filtering
One of the things a test runner should be able to do is quickly isolate one test, or a group of tests either by name (/ regex) or by filename. In addition this should be pretty fast
node --test
has a--test-name-pattern
command line switch that does this, howeverit('returns a truthy value by default')
and appear in multiple placesMotivation and Context
reduces dependencies
How Has This Been Tested?
Types of changes
Checklist
📖
⚖️