Unit Testing with Mocks in Node

added by JavaScript Kicks
3/27/2015 5:21:07 PM

1 Kicks, 169 Views

Writing tests makes the developer more certain of their work, and reduces the chance of bugs. Whether you're doing TDD or BDD, in more complex applications you will end up with a mix of unit tests & integration tests. Unit Testing is a test approach where a developer tests each feature in complete isolation. The scope is very narrow and well defined. Complex dependencies and interactions to the outside world are stubbed or mocked. Only the internal consistency is tested. Integration Testing is another approach where a developer verifies that different parts of the system work together. Multiple layers are involved and external resources (database instances, file system, network, ...) are consulted. The rest of this post will focus on unit testing.