We can test webhook callbacks with a little http server and a localtunnel.
server.js to spin up a local http server on port
8080. It just exposes a top-level route and will print the received header and payload of any request. Then create a localtunnel to have a non-local url that proxies all requests to
First, install dependencies with
Then start the express server with
|// # Mocha Guide to Testing|
|// Objective is to explain describe(), it(), and before()/etc hooks|
|// 1. `describe()` is merely for grouping, which you can nest as deep|
|// 2. `it()` is a test case|
|// 3. `before()`, `beforeEach()`, `after()`, `afterEach()` are hooks to run|
|// before/after first/each it() or describe().|
|// Which means, `before()` is run before first it()/describe()|
Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.
Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using
new Date() you are probably very new. We have adopted Upper Camel Case variable names for all module global variables