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
test: NodeJS tests using native test runner #32191
Conversation
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
Co-authored-by: Diego Sampaio <chinello@gmail.com>
Implements Node.js native test runner alongside real-world examples. Keeps swc as the compiler as well as proxyquire for module mocking in absence of native support.
c0e79c4
to
b345e41
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## meteor-3.0.0 #32191 +/- ##
=============================================
Coverage 55.04% 55.04%
=============================================
Files 2309 2309
Lines 50929 50929
Branches 10427 10427
=============================================
Hits 28033 28033
Misses 20401 20401
Partials 2495 2495
Flags with carried forward coverage won't be shown. Click here to find out more. |
e7c17a2
to
65ca774
Compare
With the introduction of Meteor 3 into the project, we now have the opportunity to utilize NodeJS version 20+. This grants us access to the native test runner, allowing us to move away from Jest and thereby enhance the overall performance of our tests.
I've crafted this PR as a draft to propose a discussion on the feasibility of transitioning to the native test runner.
Considering the pros and cons
The simplicity we'll embrace in the project—reducing our dependency count—and the performance gains are both significant points in favor. I've included a benchmark here for comparison among Jest, Mocha, and the native test runner.
Daily coding differences
When it comes to coding tests, the variances between Mocha and the native runner are minimal, primarily in the assertion aspect. Instead of relying on the popular
expect
, the native runner requires the assert library, as demonstrated in the examples available in the branch's diff. It may take a few minutes to get used of, but once done, the process becomes seamless.An important note is that the native test runner currently lacks support for mocking external modules, though it's in progress. Consequently, we'll have to continue using libraries like proxyquire.
Additionally, since our tests are written in TypeScript, we must select a compiler. Given the usage of swc in other project packages, I've opted to stick with it. This required installing the @swc-node/register library as a devDependency and integrating it into the test execution command line.
What’s next?
With a positive reception from the team, we can begin crafting an action plan. This plan will address how to handle older tests and outline our approach for implementing new ones using the potentially new methodology.