https://www.udemy.com/the-complete-nodejs-developer-course-2/learn/v4/content
https://github.com/ARWL2016/node-tests
https://github.com/ARWL2016/compendium/blob/master/reviews/testing
This module is a demonstration of basic testing methods in Node. It also covers rewire and spies. This part is not clear.
- Mocha 3.0.0 - test framework
- Expect 1.20.2 - assertion library
- Supertest 2.0.0 - for testing http requests
- Rewire 2.5.2 - dependency injection
- Mocha is not required in a test file. It is used to run tests and define test files - see package.json. It provides the describe and it structure.
- The basic structure of an expect assertion is
expect().toBe()
- Supertest allows us to make request of the app through a particular route and then expect a particular response. Note that we pass in done to make the test asynchronous.