Chapter 10. Testing with Lab, Code, and server.inject()
This chapter covers
- Writing and running tests with Lab
- Writing assertions with Code
- Testing hapi servers
- Using test spies, stubs, and mocks
Testing is a fundamental practice in the production of quality software, but there are a lot of dogma and strong opinions around testing. Regardless of whether you believe in test-first development or you write all your tests after you’ve finished building features, you should be writing tests.
The hapi contributors themselves are fully committed to testing every line of code they write. All hapi.js core projects are tested to 100% coverage. This 100% rule is enforced by default by hapi’s test runner, called Lab.
Aside from its use in the development ...
Get hapi.js in Action now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.