Instructor: Now that we have a shallow rendered component, we can use some built-in methods to search for certain nodes. Then we'll use JS's assertions to make sure that everything renders correctly. Let's write expect wrapper.find, p.length to be one.
Now, let's refactor our test, and change the wording to just contain one p element. Perfect. Now, if we go to our app file, we'll see that we only have one p tag inside of our app component. When we shallow render this with Enzyme, we want to make sure that we just see this one p element.
Then this find method will find every node in the render tree, or a wrapper that matches the provided selector that we're passing it here. We can run our NPM test script, and make sure that this test pass. We can see that it does contain just one p element.
Now, on our find method, let's change the .length to exists, and our toBe to be true. Our p tag has a classname called appIntro. Let's use that, to be more specific than just the generic p element. We've got our JS test script running in watch mode, so we are still passing on this test.
We could easily break this by changing our classname, resaving it. You can see that we fail. The exists method is handy for testing for one specific node. Now, let's say that our app had a ul with a bunch of lis.
Let's change exists to children.length, and we want that to equal three. Then inside of our app JS, let's paste in a ul with three lis. With our terminal still in watch mode, we can see that our test is still passing.
The children method is handy when scoping tests to a specific parent-child hierarchy. For example, if we added another outlying li, and saved this off, we can see that our tests still pass, because it's only looking for the children of the ul.
If our ul had a class called Tyler, we could use the hasClass method to search for specific classes. The hasClass method simply returns true or false if the class exists. Then finally, let's check that our h1 has the correct text, which is, "Welcome to React." It does, perfect.