Go ProSign in

    Integration test a Vue component with vue-testing-library

    Andrew Del PreteAndrew Del Prete

    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:



    You must be a Member to view code