unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.91k stars 497 forks source link

Add documentation for testing #2303

Open MickL opened 6 months ago

MickL commented 6 months ago

Describe the feature

The docs currently contain zero informations about testing. I am moving my backend from Nuxt to a separate Nitro app especially to have better testing abilities (Nuxt test utils need 15s to prepare tests).

I wonder if there are even any testing utilities for Nitro to support running partial tests and have HMR? Open discussion: https://github.com/unjs/nitro/discussions/194

For comparison, here are the test docs from some other huge api frameworks which are very detailed:

Further I would suggest that Nitro provides more features/support for writing tests. E.g. an automatic bootstrap/setup of the Nitro app would be great as well as fetch function for internal routes and the possibility of mocking.

Additional information

johannschopplich commented 5 months ago

For the time being, you can use nitro-test-utils, which is built upon Vitest and has a similar API to Nuxt with a $fetch method to check the body of Nitro routes.