Search⌘ K
AI Features

More on Integration Tests

Explore how to make integration tests pass by rendering React components together and managing their state. Understand the differences between unit and integration testing, the role of Selenium in simulating real user behavior, and why integration tests are essential for testing the full system under realistic conditions.

Unit tests are passing. Now what?

When we wrote the integration test in the beginning, we wanted our app to input tasks and display them. We then wrote tests to check that tasks are being saved and displayed. However, if you try running the integration test right now, it will fail:

TimeoutError: Waiting for element to be located By(xpath, //input[@placeholder='Enter new task'])
    Wait timed out after 1042ms

Now, try to recall the difference between unit and integration tests. Unit tests check the system components in isolation. They should be working perfectly fine on their own. Integration tests check the system as a whole. But the reason they are failing is because we did not never tie our components together in a system. We did not even render them!

Let’s fix that. Delete the file App.test.js, as we won’t be needing it. Then, in App.js, we will delete all the existing HTML code and render our components ...