Mocking external dependencies

In notebook:
Article Notes
Created at:
testing JavaScript
Common Unit Testing Pitfalls

A question that came up in my BDD: should I create mocks for DB interaction, file system operations or use their APIs?

The answer I've found:

If your unit tests are connecting to the file system, database, then you don’t have a unit test and you are doing it wrong. You have an integration test. Your unit tests should be testing the code that you have written and not somebody else’s.

There it is. Continue creating mocks for external libraries, modules. He's also a fan of sandboxed-module, an essential tool for my unit tests.