Kent C. Dodds 12/1/2018

React Hooks: What's going to happen to my tests?

Read Original

This article addresses a common concern when migrating to React Hooks: what happens to existing tests? It explains that tests relying on component instances (like `.instance()` or `.state()` in Enzyme) will break. It provides a solution by demonstrating how to write tests using React Testing Library that avoid implementation details, ensuring they continue to pass after refactoring a class component to a function component with Hooks.

React Hooks: What's going to happen to my tests?

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

2
Designing Design Systems
TkDodo Dominik Dorfmeister 2 votes
4
Introducing RSC Explorer
Dan Abramov 1 votes
6
Fragments Dec 11
Martin Fowler 1 votes
7
Adding Type Hints to my Blog
Daniel Feldroy 1 votes
8
Refactoring English: Month 12
Michael Lynch 1 votes
10