coding techniques I use when building React applications, • convince you that strict Test-Driven Development (TDD) is worth using, and • show you how programming from first principles is rewarding, educational and promotes high-quality code.
code to pass the test Lots of small connecting methods makes very simple testing Get rid of asynchronous behaviour Don’t access OS resources Spy tests generally comes in pairs - for the call params and for the return value
expect(actual).not.toBeDefined() expect(actual).not.toBeNull() // for querySelector expect(string).toContain(substring) For use with spies: expect(spy).toHaveBeenCalled() expect(spy).toHaveBeenCalledWith(argumentOne, argumentTwo, ...)