From the course: Testing in React with Vitest
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Testing for errors - React.js Tutorial
From the course: Testing in React with Vitest
Testing for errors
- [Instructor] After writing our first unit test, it's easy to see how we can test for many things in our page. However, a typical application written in a team can have various points of failure. For instance, let's have a look at our code. Our starting code will always be referenced by the chapter number and the video number. In this case, 02_02-start. I'll head on over to VS Code where our code is cloned. Now, working in teams where everyone has access to change small things in the code and lack of a unified linter can cause lots of breaking changes. Let's open our sum file and switch from type number to type any in any of the variables passed in our functions. So here, let's say we switch this from number to any, which means it can be anything. And here it can be anything. It might not look like it, but for most code bases, type any can be a pain if you know the exact values to test for. There's also certain rules with linters that discourage the use of any in your code base. Now,…
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.