Test a Component That Uses a React Context Provider

Dave Ceddia
InstructorDave Ceddia

Share this video with your friends

Send Tweet

Providing a Context from a component can make it tricky to test, because it requires that you use a matching Consumer in your tests. In this lesson you’ll learn how to test a component that uses a Context Provider.

Dave Ceddia
Dave Ceddiainstructor
~ 2 years ago

Note: The 'before' code for this lesson is the code from the previous lesson.

Austin Buddington
Austin Buddington
~ a year ago

Dave, are there any docs that cover which types and values that React will treat as empty? In the lesson you mentioned that true, false, null and undefined would be treated as empty when evaluated in JSX.

<span>{ false /* or any of the other values mentioned */ }</span> // => <span></span>