Testing Node.js packages is easy. Here's the condensed 1-minute guide to setting up tests on a Node.js project.
Make a package.json
file if you don't have one yet, then install your weapons of choice.
Make your first test file test/my_test.js
:
Update your package.json
to use mocha.
Type npm test
to run your tests. It should fail. Now go write tests that will pass!
Here's a quick Mocha cheatsheet. Also see mochajs.org.
Here's a quick Chai cheatsheet. See chaijs.com for other expect()
ations.
Use Sinon (sinonjs.org) for mocks.