name: write-tests description: Write or update dollar-shell tests for a module or feature. Use when asked to write tests, add test coverage, or create test files.
Write Tests
Write or update tests using the tape-six testing library.
Notes
tape-sixsupports ES modules (.js,.mjs,.ts,.mts) and CommonJS (.cjs,.cts).- TypeScript is supported natively — no transpilation needed (Node 22+, Deno, Bun run
.tsfiles directly). - The default
tape6runner uses worker threads for parallel execution.tape6-seqruns sequentially in-process — useful for debugging or when tests share state. - dollar-shell tests run OS commands, so they may behave differently on different platforms.
- Functionality tests go in
.jsfiles and are included in the main test suite (npm test). - TypeScript typing tests go in
.tsfiles intests/. They are checked bynpm run ts-checkbut are NOT included in the main tape6 test suite (preparing for Node 20 phase-out — Node 20 cannot run.tsfiles natively). - CommonJS tests go in
.cjsfiles and are included in the main test suite.
Steps
- Read
node_modules/tape-six/TESTING.mdfor the tape-six API reference and patterns. - Read the existing test files in
tests/to understand patterns and conventions used in this project. - Identify the module or feature to test. Read its source code to understand the public API.
- Create or update the test file in
tests/test-<name>.js(or.cjsfor CommonJS):- ESM (
.js):import test from 'tape-six'andimport ... from '../src/index.js'. - CJS (
.cjs):const {test} = require('tape-six')for the test framework. For the module under test, useawait import('../src/index.js')inside async tests — dollar-shell's entry point uses top-levelawait, sorequire()cannot load it. - Write one top-level
test()per logical group. - Use embedded
await t.test()for sub-cases. - Use
t.beforeEach/t.afterEachfor shared setup/teardown. - Cover: normal operation, edge cases, error conditions.
- Use
t.equalfor primitives,t.deepEqualfor objects/arrays,t.throwsfor errors,await t.rejectsfor async errors. - All
msgarguments are optional but recommended for clarity.
- ESM (
- Run the new test file directly to verify:
node tests/test-<name>.js - Run the full test suite to check for regressions:
npm test- If debugging, use
npm run test:seq(runs sequentially, easier to trace issues). - To see which files are being run, add
--flags fo(overrides the default--flags FO).
- If debugging, use
- Report results and any failures.