This file describes how to exercise the validation, lint, and format tooling that backs @git-stunts/trailer-codec so you can ship documentation or code changes with confidence.
- Node.js 20.x (per
package.jsonengines) so Vitest, ESLint, and the ESM modules run without warnings. - Run
npm installonce after cloning to populatenode_modules.
| Script | Description |
|---|---|
npm test |
Runs Vitest over test/unit. Pass additional arguments (e.g., npm test -- test/unit/domain/services/TrailerCodecService.test.js) to limit which files execute. Append --reporter=verbose for detailed output or --no-color for colorless logs. |
npm run lint |
Executes ESLint across the entire repository. Fix any reported issues locally. |
npm run format |
Runs Prettier with the configured settings to keep formatting consistent. Commit the formatted files or run with --check before publishing documentation. |
Use npm test -- --watch to run Vitest in watch mode while you iterate.
- Add unit files under
test/unit/following the existing structure (mirrorssrc/). - Mock dependencies with Vitest helpers (
vi.fn,vi.mock) when you do not need to exercise the real parser/service. - Snapshot tests (for serialized codec outputs or CLI/help text) verify that binary/JSON/text outputs remain stable. Regenerate them only after an intentional, reviewed change: run
npm test -- -ulocally, inspect the diff carefully, include the updated snapshots in the same PR with a clear rationale, and rely on CI to flag any unexpected snapshot drift before the merge.
- If the suite fails due to missing modules, delete
node_modulesand rerunnpm install. - ESLint/Prettier share the
eslint.config.js/.prettierrcconfigurations; runnpm run lintfirst to enforce syntax, thennpm run formatto correct formatting drift.