From the course: Testing in React with Vitest
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Integrating Vitest with the React Testing Library - React.js Tutorial
From the course: Testing in React with Vitest
Integrating Vitest with the React Testing Library
- [Presenter] I hope you're able to complete the challenge. You can find the chapter code with all the necessary code. I worked in a couple of teams where developer tools were an absolute pain. In this lesson, we'll get our hands dirty by learning how to write our fast unit test with Vitest as a test runner, and, finally, use testing library React to test our components. We've written a couple of tests, but Vitest can do more than write tests for us. It can run tests by integrating with external testing libraries to make testing a breeze. To get started, we'll follow a similar pattern with what we've been doing. If we look at our app, we've done basic testing, but now we want to render our views in the tests so we can guarantee the output. Let's create a new test file in our test folder and call it App.text.tss. We'll begin by importing our necessary dependencies. We'll import describe, expect, and it from Vitest. Then we'll import render and screen from React testing library. Here…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.