Introduction
Testing in NFW-HTTP is aimed to be easy as possible and agnostic of the testing library.
For the demonstration, jest is the testing library for the different code examples.
Note
The functions used for testing will be refined in the future. But the testing procedure stays the same.
Understanding resolution and execution
In order to test a guard, a param, or a response handler. You need to understand the 2 steps done by the framework to translate the metadata generated by your decorators.
1. Resolution
First, the metadata are fetched from the MetadataStorage by the Resolver
.
The Resolver
then returns an Executable
for a specific controller context.
2. Execution
The Executable
is executed each time a request is made to your endpoint in a specified RouterContext
.