An example code from coddee. These are a set of tests written using mocha and chai.
In webhook_method_tests.js
, I am testing that the method saves a MongoDB document into a collection.
In webhook_tests.js
, I am testing that this method is called when a webhook comes in from GitHub.
I wrote two different tests because the middleware that detects the GitHub webhook is an event emitter, and I don't have much control over how long it takes to actually save a document to a collection.