name: write-tests description: Write or update tape-six tests for a module or feature. Use when asked to write tests, add test coverage, or create new test files for stream-csv-as-json.
Write Tests for stream-csv-as-json
Write or update tests using the tape-six testing library.
Steps
- Identify the module or feature to test. Read its source code to understand the public API.
- Check existing tests in
tests/for stream-csv-as-json conventions and patterns. - Create or update the test file in
tests/:- ESM tests use
.mjsextension, CJS tests use.cjs, TS tests use.mts. import test from 'tape-six';import chain from 'stream-chain';- Import the module under test with relative paths:
import parser from '../src/parser.js'; - Use
tests/read-string.mjshelper for streaming strings in configurable chunks. - Use
test.asPromise('name', (t, resolve, reject) => { ... })for async stream-based tests. - Use
t.deepEqual(),t.equal(),t.ok()for assertions.
- ESM tests use
- Test file naming must match
test-*.mjs(ESM),test-*.cjs(CJS), ortest-*.mts(TS) — the tape6 config in package.json globs for these patterns. // turbo - Run the full test suite to verify:
npm test - Run TypeScript type checking:
npm run ts-check - Report results and any failures.
stream-csv-as-json conventions
- Test file naming:
test-*.mjs(ESM),test-*.cjs(CJS),test-*.mts(TS) intests/. - ESM tests use
import, CJS tests userequire(). test.asPromise()for stream-based async tests with resolve/reject callbacks.- Common pattern: create a pipeline with
chain([readString(input), component()]), collect output in an array via'data'events, verify on'end'witht.deepEqual(). - Use
readStringhelper fromtests/read-string.mjsfor testing chunked input at configurable chunk sizes. - Source modules are in
src/:parser.js,as-objects.js,stringer.js,index.js,utils/with-parser.js.