This repository was archived by the owner on Jul 24, 2026. It is now read-only.
New: Add unit tests with node:test framework - #33
Merged
Merged
Conversation
Co-authored-by: taylortom <1059083+taylortom@users.noreply.github.com>
Co-authored-by: taylortom <1059083+taylortom@users.noreply.github.com>
Co-authored-by: taylortom <1059083+taylortom@users.noreply.github.com>
Co-authored-by: taylortom <1059083+taylortom@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add unit tests for module using Node.js built-in library
New: Add unit tests with node:test framework
Feb 10, 2026
taylortom
marked this pull request as ready for review
February 19, 2026 23:14
|
🎉 This PR is included in version 1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
New
AdaptError(23 tests) andErrorsModule(9 tests) using Node.js built-innode:testandnode:assert/strictnpm testscript in package.json:node --test 'tests/**/*.spec.js'.github/workflows/tests.ymlwith explicit permissions and pinned action versions (@v4).gitignorefor node_modules exclusionTesting
npm test- 32 tests should passnpx standard- linter should pass with no errorsTest Coverage:
Original prompt
This section details on the original issue you should resolve
<issue_title>Add unit tests</issue_title>
<issue_description># Writing tests
Instructions for writing tests in this module.
Stack
node:test(built into Node.js)node:assert/strictNo external test dependencies are needed. Do not introduce Mocha, Jest, or other test frameworks.
File placement and naming
tests/directory at the module root<moduleName>.spec.jstests/data/File structure
Every test file follows this structure:
Key rules:
describe,it,before,afteretc. fromnode:testassertfromnode:assert/strict(strict mode usesdeepStrictEqualby default)importsyntax — this project is"type": "module"describeblocks, prefixed with#for instance methodsletvariables scoped to thedescribeblockAssertions
Use
node:assert/strict. Common patterns:Dynamic test generation
When testing a function against multiple inputs, generate tests in a loop:
Async tests
node:testsupportsasync/awaitdirectly:Test data
Place fixture files in
tests/data/. Useimportorfsto load them:What to test
assert.throws/assert.rejects)What NOT to do
_)node:testandnode:assertare sufficientdescribeblocksAdd script to package.json
The tests should be accessible via an npm script in package.json:
Add GitHub workflow
The following workflow should be added to /.github:
Running tests
Both must pass before submitting a pull request.
</issue_description>
Comments on the Issue (you are @copilot in this section)
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.