testing-library/vue-testing-library

Unable to make mocking or stubs

juancampuzano opened this issue · 3 comments

If I can't use shallow rendering, how do I mock out components in tests?

In the documentation there is a way to mock a feature, but this is only working in the following library: @testing-library/jest-dom

image

In the example you will see that it is importing the @testing-library/jest-dom library on line #2 instead using @testing-library/vue

Do I need to install that library to make the mocking? Or Is there a way to do it in the @testing-library/vue library?

I found the error in the documentation you haven't the stubs property inside the global property

import {render} from '@testing-library/vue'
import Component from './Component'

test('Can stub components', () => {
  render(Component, {
     global: { stubs: ['FontAwesomeIcon'] },
  })
})

@juancampuzano Thanks! I was stuck on this for quite awhile because the documentation is incorrect.