-
Notifications
You must be signed in to change notification settings - Fork 22
test: replace ava with node:test #467
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: replace ava with node:test #467
Conversation
This bumps the Node.js version from 18.12 to 18.16, which includes a fix for a segfault when using c8 for code-coverage collection.
This commit replaces ava with the Node.js native test runner[^1]. The naive implementation ran each test in the test corpus serially, due to this nature of the native test runner's execution model[^2]: > Each test file is executed as if it was a regular script. That is, > if the test file itself uses node:test to define tests, all of those > tests will be executed within a single application thread, regardless > of the value of the concurrency option of test(). Since the function under test is synchronous and compute-bound, and Node.js is single-threaded, all the tests were executing serially and took over 30s to complete on my macbook. Consequently, this commit uses Node.js worker threads[^3] to spawn one worker per test-corpus file, limited to one worker per CPU core. In this configuration, all tests complete in 17s on my macbook. [^1]: https://nodejs.org/api/test.html [^2]: https://nodejs.org/api/test.html#test-runner-execution-model [^3]: https://nodejs.org/api/worker_threads.html
|
New dependency changes detected. Learn more about Socket for GitHub ↗︎ 🚨 Potential security issues found in this pull request. To accept the risk, merge this PR and you will not be notified again. Bot CommandsTo ignore an alert, reply with a comment starting with
📜 Install scriptsInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts. Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.
Pull request alert summary
📊 Modified Dependency Overview:
🚮 Removed packages: @ava/typescript@3.0.1, ava@5.2.0 |
9237601 to
40d3123
Compare
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.
Please note this diff, where we necessarily stop running unit tests on Node.js 14 and 16. I personally am all right with this change, but would love to hear what you think!
bitgopatmcl
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.
This works ![]()
|
🎉 This PR is included in version @api-ts/io-ts-http@2.4.0 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version @api-ts/express-wrapper@1.0.18 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version @api-ts/openapi-generator@1.0.9 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version @api-ts/superagent-wrapper@1.1.11 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version @api-ts/typed-express-router@1.1.0 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
This PR replaces ava with the Node.js native test runner1.
The refactor was straightforward in the express-wrapper and the typed-express-wrapper, but there are some notable changes in the openapi-generator.
The naive implementation ran each test in the test corpus serially, due to this nature of the native test runner's execution model2:
Since the function under test is synchronous and compute-bound, and Node.js is single-threaded, all the tests were executing serially and took over 30s to complete on my macbook.
Consequently, this commit uses Node.js worker threads3 to spawn one worker per test-corpus file, limited to one worker per CPU core. In this configuration, all tests complete in 17s on my macbook.
Supersedes #465
Footnotes
https://nodejs.org/api/test.html ↩
https://nodejs.org/api/test.html#test-runner-execution-model ↩
https://nodejs.org/api/worker_threads.html ↩