Test Driven Development in React with Jest and Enzyme

Exploring snapshots, mock functions simulation testing and more

Ross Bulat
12 min readMar 7, 2019

Introduction: How do you Develop?

This talk covers a range of testing tools that Enzyme and Jest offer for React, ranging from snapshot testing, mock functions, simulating events, and how to test component functions, props and state. We will also explore other aspects of testing including abstract-ability and logic isolation within your React projects, and finally wrap up with a testing checklist to adhere to when designing your own tests.

Enzyme and Jest are critical tools that can ensure a high level of stability to your code from your first deployment, and can be used whether you are adopting a Test Driven Development or Behaviour Driven Development strategy. Before jumping into the tools let’s review the differences between these two development approaches in an abstract way.

Behavioural Driven Development

How much time do you spend testing your apps? Is it done after a milestone or at intervals as you are developing components? The former approach gives precedence to the behaviour of the app, prioritising business logic completion over component stability. Your testing suites will be coded once the…

--

--

Ross Bulat
Ross Bulat

Written by Ross Bulat

Programmer and Author. @ Parity Technologies, JKRB Investments

Responses (5)