Skip to content

Instantly share code, notes, and snippets.

@ravinggenius
Created September 9, 2014 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravinggenius/eb233d8e7d2ca8a31ea3 to your computer and use it in GitHub Desktop.
Save ravinggenius/eb233d8e7d2ca8a31ea3 to your computer and use it in GitHub Desktop.
var Hapi = require('hapi');
var server = new Hapi.Server('localhost', 5000);
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply('hello world');
}
});
module.exports = server;
{
"name": "hapi-mocha",
"version": "1.0.0",
"description": "Simple app to demonstrate Hapi and Mocha issue",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"author": "Thomas Ingram",
"license": "MIT",
"dependencies": {
"hapi": "^6.8.0"
},
"devDependencies": {
"mocha": "^1.21.4"
}
}
var assert = require('assert');
var server = require('./index');
describe('GET /', function () {
var request = {
method: 'GET',
url: '/'
};
it('just works', function (done) {
server.inject(request, function (response) {
assert(response.payload === 'hello world');
done();
});
});
it('times out', function (done) {
server.inject(request, function (response) {
assert(response.payload === 'hello-world');
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment