Disguise-Driven Testing: Jest Mocks in Depth

1 · Nicolás Bevacqua · March 28, 2019, 3:18 a.m.
Testing can be simple. In fact, it is simple. Well, it is simple until impurities slip in. Code that would be easy to test becomes a nightmare as soon as you get impure data (like date checks) or complex external dependencies (such as DOM manipulations or large 3rd party libraries). The part that tends to frustrate developers most is when they have code that’s easy to read, easy to write, but difficult to test. No one wants to spend more time on their tests than they do on their code.Consider an...