Dans le cours : React.js Essential Training

Accédez au cours complet aujourd’hui

Inscrivez-vous aujourd’hui pour accéder à plus de 23 100 cours dispensés par des experts.

Introducing React Testing Library

Introducing React Testing Library

- [Instructor] Another test utility that's built directly into create React app is React testing library. So let's take a closer look at how we might use this in our own project. And to do so, we're going to start by creating a new component called Star. And then we'll also create a file called Star.test.js. And remember that Jest is going to run any of these test files if they end in that .test.js extension. So in the Star.js file, we're going to export our function. And our Star is going to display the following. We'll just say Cool Star. So now that I've created that, we're going to open up our Star.test.js. Having things side by side is nice. And we're going to use a function called test to say renders an h1. So remember, we're not actually rendering this to the DOM anywhere. This is a brand new component that we haven't actually rendered. It's important to know that it doesn't matter. We can use these test…

Table des matières