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.

Snapshot testing: Part 1

Snapshot testing: Part 1

- [Instructor] There are various ways of testing applications, and one of them is snapshot Testing. We just covered unit testing. In this video we'll write our first snapshot test and understand where we might need snapshot testing. Snapshot testing is a form of testing where you ensure the output of your function doesn't change unexpectedly. This is useful when comparing whether the components rendered output has changed. Vitest offers a simple and straightforward API to write snapshot tests and can be written in the component directly. Since Vitest has hot module replacement, it allows for real-time feedback on snapshot changes. This makes it easier to change and test your app in real time. While it's a good way of testing, it's important to remember that overly granular snapshots can become brittle and break from minor UI adjustments. We'll head back to VS Code, and our starting code will be in Branch 02_03-start. Our application is still simple. However, we want an application…

Contents