From the course: JavaScript: Test-Driven Development (ES6)

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

When shouldn't I use test doubles?

When shouldn't I use test doubles? - JavaScript Tutorial

From the course: JavaScript: Test-Driven Development (ES6)

Start my 1-month free trial

When shouldn't I use test doubles?

- [Instructor] Now test doubles might seem like a really nice tool to work with when doing TDD, but be careful. Normally what happens when people first learn how to use test doubles is that the they go off and start using them for everything in their tests, and this is really the wrong way to do it. This bears repeating. Test doubles, when used in the wrong places, can be a bad thing. While it's usually okay and even necessary to use test doubles for time-consuming things like network operations, and there are exceptions to this as well, most other use cases for test doubles are an indication of an underlying problem in the code base. As an example, let's look at one of the most common situations where I see developers wrongly using test doubles. Many times test doubles are used as a sort of bandaid for unit tests where a lot of setup code is required to test the desired piece of functionality. When working in…

Contents