ava
Introduction
Ava is an incredibly fast and asynchronous testing framework. Light has a built in test
function that can be used to build and test individual routes very easily.
Setup
First, create a test file for your route. As of right now the file cannot live inside of the routes
folder as all files are automatically imported. Once your file is created, populate it with the following.
You will need the node-fetch
dependency to actually make the requests to the server, but you may swap it out with any other similar library. The test
function takes in a route and boots up a server, returning an object with a url
property and a close
function. The before
and after
functions will boot up the server for the tests. Finally, inside the test you can do anything you will like with the server.url
. Keep in mind that whatever route is passed becomes mapped to /
and does not follow the routes defined in routes.js
. Additionally, destructuring test
from the light
variable will not work.
Last updated