Integration test a Vue component with vue-testing-library

Share this video with your friends

Send Tweet

In this lesson, we'll use vue-testing-library along with Jest to write some integration tests for a Counter component. What's nice about the vue-testing-library and it's equivalents like dom-testing-library and react-testing-library is that it has several functions to retrieve and assert on elements like a user would when interacting with your application.

When a user clicks a button, they're not clicking on a CSS class (as some testing libraries suggest), they're clicking on a button labeled "Increment". The user doesn't know about the implementation details, so testing an app this way makes sense. We'll look at several of the getBy* functions vue-testing-library offers to test our component.

Additional Resources:

Free Community Resource

A Community Resource means that it’s free to access for all. The instructor of this lesson requested it to be open to the public.