Skip to content
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

Not able to mock $root #1877

Closed
hilkisahil opened this issue Nov 18, 2022 · 1 comment
Closed

Not able to mock $root #1877

hilkisahil opened this issue Nov 18, 2022 · 1 comment

Comments

@hilkisahil
Copy link

I'm using vue 3 and vue-test-utils v2 . I have a component which uses $root to listen events. When I try to test this component it fails by throwing error 'this.$root.$on' is not a function.
I have even tried using mounting options 'parentComponent' but not working.

const Parent = {
  data() {
    return {
      $on: jest.fn(),
    }
  }
}
const wrapper = shallowMount(TestComponent, {
  parentComponent: Parent
})

MicrosoftTeams-image (5)

@cexbrayat
Copy link
Member

Hi @hilkisahil

If you are using vue v3.2.45, then yes there is a change in vue core that we have to work around in VTU
We already have the fix, and we are going to release it soon

Closing as duplicate of #1869

@cexbrayat cexbrayat closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants