Categories hapi

19 posts

Auto Added by WPeMatico

hapi β€” Inject Request Payload, Headers and Parameters While Testing Route Handlers

Testing in hapi builds on top of a single method: server.inject. Injecting requests is a core element in testing your hapi app. A previous tutorial walked you through the basics of injecting requests to test route handlers. What we didn’t cover there is the ability to inject requests with payload, […]

🌟 learn hapi β€” Update Mongoose Models for JSON Responses

While creating the Futureflix API, you noticed that the JSON representation of documents contains the _id and version key __v. The _id field feels wrong due to the underscore prefix, so let’s remove it and keep only the id field. The version key __v isn’t necessary in the response at […]

hapi β€” Test Route Handlers by Injecting Requests

One of the reasons we’re passionate about hapi is its easiness of testing. The framework has a built-in server.inject method that simulates an incoming HTTP request. A server.inject call won’t create a socket connection. You’re not relying to the network stack to run tests in your app. That means, testing […]

hapi β€” Run Tests with Assertions using Code

Testing your hapi applications might require expected values and responses that match a set of data. The code library from hapi’s ecosystem is an assertions library based on chai. Code exposes an expressive and readable language-style interface. You’ll get a grasp on features and the usage in the upcoming sections. […]