Write Tests for stream-chain
Write or update tests using the tape-six testing library.
Steps
- Read
node_modules/tape-six/TESTING.mdfor the full tape-six API reference (assertions, hooks, patterns, configuration). - Identify the module or feature to test. Read its source code to understand the public API.
- Check existing tests in
tests/for stream-chain conventions and patterns. - Create or update the test file in
tests/:- For runtime tests use
.mjs, for typing tests use.mts, for CommonJS tests use.cjs. - Import the module under test with relative paths:
import chain from '../src/index.js'; - For stream tests, collect output with
pipeline.on('data', ...)and verify inpipeline.on('end', ...). - Use
tests/helpers.mjsutilities:streamToArray(),readString(),writeToArray(),delay().
- For runtime tests use
- Run the new test file directly to verify:
node tests/test-<name>.mjs - Run the full test suite to check for regressions:
npm test- If debugging, use
npm run test:seq(runs sequentially, easier to trace issues).
- If debugging, use
- Report results and any failures.
stream-chain conventions
- Test file naming:
test-*.*jsandtest-*.*tsintests/. - Runtime tests (
.mjs): ESM imports,import test from 'tape-six'. - TypeScript typing tests (
.mts): verify type declarations and type-safe API usage. Seetests/test-typings-*.mts. - CommonJS tests (
.cjs):const {test} = require('tape-six');. Seetests/test-cjs.cjs. - Existing tests use
test.asPromise('name', (t, resolve) => { ... })for stream-based tests. New tests may also useasync t => { ... }when appropriate. - Tests run on Node, Bun, and Deno.
Source: uhop/stream-chain — distributed by TomeVault.