Unit testing versus Express.js application integration testing
I am writing tests for an Express.js application and I have no idea how to choose between unit tests and integration tests.
I am currently experimenting with:
unit tests - using Sinon for stubs / mocks / spies and Injects for dependency injection for modules. with this approach i have to stub MongoDB and other external methods.
I thought about unit testing the individual routes and then using an integration test to make sure the correct routes were actually called.
integration tests - using Supertest and Superagent, much less code to write (no need to mock / stub anything), but a test environment (databases, etc.) must exist
I am using Mocha to run both test styles.
how to choose one of two different approaches?
+3
source to share