Node.js has introduced a stable test runner in its standard library starting from version 18. This inclusion aims to emphasize the importance of testing as an integral part of development and to provide core tooling out-of-the-box, addressing the minimalist philosophy traditionally held by Node.js. The post walks through the core capabilities of the test runner, from writing and executing tests to organizing and customizing them. It also demonstrates the usage through examples, showing how to write unit tests, run them, handle test failures, and organize test cases.
Table of contents
What Is Testing?Why Was A Test Runner Added to Node.js 18+?PrerequisitesSetting Up a Demo ProgramTesting Your Node.js CodeWhat Happens When You Run node --testDealing with Test FailuresOrganizing Test Cases with SubtestsUsing the Describe/It SyntaxCustomizing Test RunsMarking tests as "TODO"Wrapping Up1 Comment
Sort: