hapi-test
Test hapi plugins with chaining method calls and assertions.
Assertions
Using the end method you can write your own assertions in anyway you want.
//chai assertionsvar hapiTest = plugin = assert = assert; ;
Status code
If you want to test status code you can simply assert the statusCode number
Headers
To test a header value you can do an assert with header name as first parameter and header value as second. Works with strings.
//string ;
Async testing
If you are using mocha you can pass in the done function to any assertion as last parameter.
;
Mocha also supports promises.
;
Keep instance of server to speed up tests
If you have multiple tests on the same server / plugins you can create an instance of the server and use this in the constructor. This will speed up the tests as it does not need to create a new server and initialize the plugins for each test.
// example using mochavar hapiTest = Hapi = plugin = assert = assert; var server; ; ;