readme-assert¶
README.md files often become outdated because the code examples are
not regularly tested. readme-assert extracts fenced code blocks from
your readme and runs them as tests, using special comments as assertions.
Install¶
Quick Start¶
Add test assertions to code blocks in your README.md:
Run:
That's it. If any assertion fails, the process exits with a non-zero code.
How It Works¶
- Each fenced code block is extracted from the markdown
- Blocks with the same
test:groupname are merged; others run independently - Assertion comments (
//=> value) are transformed intoassert.deepEqual()calls - Imports of your package name are rewritten to point to your local source
- Each block is written to a temp file and executed with
node