Writing tests can either be a quick 5 minute job, it can also be a few hours of hell. The differentiator... is mainly down to how the component has been written. For a lot of codebases that I come across, writing tests is usually harder than it needs to be. Codebases that are hard to test, usually occur when the developers in the team think of tests as an afterthought.
I've been writing and code reviewing tests for over a decade. Due to that experience I tend to naturally build my components in a test friendly way. Some people reading this might be test-first evangelist and no developer should write code until a test has been written. I do agree high-test coverage is an essential part of the development life-cycle, there are situations you just need to get somethings working, then refine it and write tests after you understand a problem is abetter approach.
In this section you will find code examples and tutorials that will help you to test your react components.
In this tutorial, I will share some code with you that checks that some content exists within a div with a specific class name. The main reason I've written this tutorial is because I've wasted the last two hours trying to write a test and completely[...]
In this tutorial, you will find a number of code examples that cover a range of different testing scenarios that I've needed to write for some of the react.js websites I've worked on.
Basic Snapshot Test Example
Snapshot tests are useful to make su[...]