Using Jest and Supertest to add unit and functional test to Node App.
Test |
Api Demo Result |
---|---|
![]() |
![]() |
There are two types of tests, the unit tests and the functional tests. These can be executed as follows.
-
Run unit tests only
$ npm run test:unit
-
Run functional tests only
$ npm run test:functional
-
Run both unit and functional tests
$ npm run test
Run the application which will be listening on port 3000
.
$ npm start
There are two environments in Docker Compose. These can be executed as follows.
-
Run development environment
$ docker-compose -f docker-compose.dev.yml up --build
-
Run production environment
$ docker-compose -f docker-compose.yml up --build
-
Run tests inside Docker container
$ docker build -t node-docker --target test .
https://docs.microsoft.com/en-us/learn/modules/deploy-nodejs/ https://github.com/MicrosoftDocs/node-essentials