While established testing frameworks like Jest and Mocha have long served the Node.js community, Vitest emerges as a compelling alternative, especially for projects that leverage TypeScript and modern tooling.
Vitest boasts a rich testing ecosystem out of the box, including features like test coverage and optional visual test explorers for enhanced development experience.
In this article i will walk over the setup for vitest with serverless framework for node and express applications.
The serverless.yml file remains almost unchanged, just add an exclude section under package to discard the test files when serverless build is getting created and deployed.
Vitest.config.json
Since the serverless framework encourages the use of config.stage.json files and environment files, i had slight trouble getting environment files to work with vite, so i came up with the above function that reads the .json
as well as .env
files and loads the environment variables.
The variable CONFIG_FILE
is passed during the run time.
I hope you like this short article, thanks for reading :)
Abd038
Socials:
https://www.linkedin.com/in/abdul-mohammad-a567b2183/
https://twitter.com/iam_abd038
https://github.com/iam-abdul
Top comments (0)