From the course: React: Testing and Debugging

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Test arrays and objects with matchers

Test arrays and objects with matchers - React.js Tutorial

From the course: React: Testing and Debugging

Start my 1-month free trial

Test arrays and objects with matchers

- [Instructor] Often you'll work with arrays and objects in your data, and you'll need to test various scenarios related to these types. Jest offers a few specific object and array methods, which you can use in combination with other methods. Let's take a look at how to use them. So first, I'm going to go back into my Grid.test.js inside of my listing folders, inside of components. And what I'm going to do first before writing any code or testing code, I'm going to create an array. Let's go ahead and create that. So, I'm going to put some notes here, so this is Arrays, and then what I'm going to do is create an array. So, let's go ahead and create and array called data2. And we're going to pass inside of that array two titles, so two strings. So, one is going to be React Native, and the other one is going to be React, like so. And then, we're going to start testing. So, basically, one of the methods that we can use for arrays…

Contents