Unit Testing with Node.js
2019, Jan 10
Unittest with MongoDB (In-memory Database)
Document for the idea of in-memory MongoDB instance: https://jestjs.io/docs/en/mongodb
A working example: https://github.com/backslash112/jest-mongodb
Useful Commands
Use dotenv Envirement varible in Jest:
jest --setupFiles dotenv/config
Show converage report in Jest:
jest --coverage
Run all tests serially in the current process:
jest --runInBand
Reference
- https://jestjs.io/docs/en/cli
- https://jestjs.io/docs/en/expect