/nodejs-express-tdd

A TDD exercise on NodeJS with Express and MongoDB.

Primary LanguageJavaScript

NodeJS Express TDD

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 response
  • middlewares: executes checks and validation such as authentication, authorisation, valid input values
  • services: calls one or multiple repositories and emits events
  • repositories: calls one object entity (model) only
  • models: database schema

Objectives

  • 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 (?)

Test Libraries

  • jestjs
  • sinon to create stubs for expected results in each individual test for isolation
  • supertest to make request to Express

Resources