net - UK (2020-01)

(Antfer) #1

PROJECTS
React


REACT


O Mocking: creates pretend functions, so that you
can check your assumptions

Over the course of this article, I’m going to explore
some examples from the React Testing Library in
order to help you get started with this valuable way
of improving the robustness of your code output, as
well as ensuring your code doesn’t throw up any nasty
surprises once it goes into production.

GETTING STARTED WITH REACT
TESTING LIBRARY
I’m going to use create-react-app for this demo because

UNIT TEST YOUR REACT


SITES AND APPS


Want production-ready frgh#zlwkrxw#jrlqj#wr#surgxfwlrq#ĽuvwBBen Read


vkrzv#krz#lwġv#srvvleoh#zlwk#Uhdfw#Whvwlqj#Oleudu|


Do you really know your code does what it is
supposed to do? Have you tested it in the
browser? What if you haven’t – or you can’t test
everything – and it breaks in production?
A testing library is a group of utilities developers
use to write individual tests on our application
components. Some of the principle parts
of a test are:

O Description: describes what the test is about

O Use / Render: uses the component in an
environment where it can be tested

ABOUT THE AUTHOR
BEN READ
t: @muzzlehatch_
job: Designer and
developer
areas of expertise:
JavaScript, React and UX
Free download pdf