Test runner for doctests using JSDoc examples and node-tap.
npm i -D jsdoctap
I recommend adding it to your npm scripts. Example:
jsdoctap has one option:
jsdoctap -i src/*.test.js -i src/*.config.js src/*.js.
Tests must be under an
@example in a valid JSDoc comment.
The return value to be tested against must come after a line comment with an
arrow (Clojure REPL style):
/*** Identity* @example* id(1) // => 1*/
Line breaks between the call and the comment are fine:
/*** Identity* @example* id(1)* // => 1*/
Line breaks in function calls currently do not work:
/*** This will break!* @example* id(* 1* ) // => 1
Source and examples that need to be Babelified work just fine, as long as you have Babel configured and modules installed.