Draft
Conversation
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 test library
New: Add unit tests
Feb 10, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
node:testandnode:assert/strictnpm test)Update
exportsfield to package.json to enable self-referencing imports (adapt-authoring-assets/lib/*)permissions: contents: readfor securityTesting
npm testto execute test suitenpx standardto verify linting complianceTests verify module exports and static properties. All peer dependencies are available during test execution via npm ci.
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.