# Write Tests

> Write or update tape-six tests for a module or feature. Use when asked to write tests, add test coverage, or create typing tests for stream-json. Use when this capability is needed.

- Skill: `tomevault-io/write-tests-5` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/write-tests-5`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/write-tests-5/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/write-tests-5

---


# Write Tests for stream-json

Write or update tests using the tape-six testing library.

## Steps

1. Read `node_modules/tape-six/TESTING.md` for the full tape-six API reference (assertions, hooks, patterns, configuration).
2. Identify the module or feature to test. Read its source code to understand the public API.
3. Check existing tests in `tests/` for stream-json conventions and patterns.
4. Create or update the test file in `tests/`:
   - Runtime tests use `.mjs` (ESM).
   - Import the module under test with relative paths: `import {parser} from '../src/index.js';`
   - For stream tests, use `chain()` from `stream-chain` to build pipelines.
   - Collect output with `pipeline.on('data', ...)` and verify in `pipeline.on('end', ...)`.
   - Use helpers from `tests/read-string.mjs` and `tests/counter.mjs`.
5. Run the new test file directly to verify: `node tests/test-<name>.mjs`
6. Run the full test suite to check for regressions: `npm test`
   - If debugging, use `npm run test:proc` (runs sequentially, easier to trace issues).
7. Report results and any failures.

## stream-json conventions

- Test file naming: `test-*.mjs` in `tests/`.
- Runtime tests (`.mjs`): ESM imports, `import test from 'tape-six'`.
- Existing tests use `test.asPromise('name', (t, resolve, reject) => { ... })` for stream-based tests.
- New tests may also use `async t => { ... }` when appropriate.
- Common pattern: build a `chain()` pipeline, collect output in an array, verify on `'end'`.
- Tests run on Node and Bun.

---
> Source: [uhop/stream-json](https://github.com/uhop/stream-json) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-06-18 -->

