Like strings and numbers, you can test for a number of other elements with Jest. In this video, Emmanuel Henri explores the types of tests you can do with Jest's matchers for arrays and objects. Pulling from the data feeding the app, he tests for a number of scenarios.
- [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 … is to use arrayContaining as a method, …
- Setting up for React testing and debugging
- Testing with Jest
- Snapshot testing
- Debugging with Chrome and Chrome extensions
- Optimizing React code with ESLINT
- Type checking