Skip to content

Unable to make mocking or stubs #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
juancampuzano opened this issue Jan 9, 2023 · 3 comments
Closed

Unable to make mocking or stubs #291

juancampuzano opened this issue Jan 9, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@juancampuzano
Copy link

juancampuzano commented Jan 9, 2023

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?

@juancampuzano juancampuzano added the bug Something isn't working label Jan 9, 2023
@juancampuzano
Copy link
Author

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'] },
  })
})

@jasosims
Copy link

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

@afontcu
Copy link
Member

afontcu commented Mar 13, 2023

juancampuzano added a commit to juancampuzano/testing-library-docs that referenced this issue Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants