mecha
Ensure your node examples/*.js work by using them as mocha tests.
Setup
Add mecha
to your package.json devDependencies
npm install
Usage
Now your example files can use mocha when run.
var mecha = require('mecha');
mecha.log("This will be printed only when run directly as an example");
mecha({reporter: 'dot'});
Users run your example, and see the message printed above
node examples/awesome.js
But when run as a test, they see test reports.
mocha examples/awesome.js
You can therefore include your example files to your test harness,
add a test/examples.js
file to your project
require('../examples/awesome')