testdoc
Test your documentation
Last updated 4 years ago by andreypopp .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install testdoc 
SYNC missed versions from official npm registry.

testdoc

Test your documentation.

Snippets like this:

Ok, let's test addition:

```js+test
2 + 2
// => 4
```

are coverted into runnable Mocha test suites which can be tested with the following command:

% mocha --compilers md:testdoc/register ./README.md

Installation & Usage

Install with:

% npm install testdoc mocha

Run with:

% mocha --compilers md:testdoc/register ./README.md

Assertions against text representation

Trailing comments which starts with => are treated as assertions against textual representation of an expression which goes before:

2 + 2
// => 4

Regular assertions

Also assert Node.js module is available so you can use it directly:

assert(2 + 2 === 4)

Assertions for errors

If trailing comment is detected and start with Error: (actually any error name which ends with Error suffix) line then it is treated as an assertion against an error being thrown:

let maybeFunction = undefined;

undefined()
// TypeError: undefined is not a function

Current Tags

  • 0.2.1                                ...           latest (4 years ago)

3 Versions

  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 6
Dependencies (10)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |