A TDD exercise on NodeJS with Express and MongoDB(?).
Folder structure is as follows:
controllers
: responsible for accepting requests, calls respective service and provide a responsemiddlewares
: executes checks and validation such as authentication, authorisation, valid input valuesservices
: calls one or multiple repositories and emits eventsrepositories
: calls one object entity (model) onlymodels
: database schema
- Implement unit test for each of the above service in isolation, mocking dependencies as required.
- Implement integration test for each API endpoint with test database (?)
jestjs
sinon
to create stubs for expected results in each individual test for isolationsupertest
to make request toExpress