[Bug Report] Unable to mock $vuetify in unit tests
See original GitHub issueEnvironment
Vuetify Version: 2.2.11 Vue Version: 2.6.11 Browsers: Safari 13.1 OS: Mac OS 10.14.6
Steps to reproduce
- yarn
- yarn test:unit
- open file example.spec.js and see snapshot result.
Expected Behavior
I want to mock instance variable $vuetify.breakpoint.smAndDown
by providing a mock like described in the docu https://vuetifyjs.com/en/getting-started/unit-testing/ and https://vue-test-utils.vuejs.org/api/options.html#mocks. I installed Vuetify like described in a config file setup.jest.js
and configured jest to use it.
I expected that in my test that mocked smAndDown
is set to true
.
Actual Behavior
$vuetify
instance variable is not mockable. The actual implementation is not overwritten by passing a mock object either to new Vuetify()
nor to shallowMount
or mount
.
Reproduction Link
https://github.com/Bastczuak/vuetify-mock-issue
Other comments
Please fix the issue creator! I was not able to create an issue in Chrome browser because after submitting a new issue I got redirected to my account email settings.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10 (2 by maintainers)
This is for my people who are coming from google. After reading code and trying around, I now have a working solution for mocking vuetify services in unit tests. But be careful, I have no idea if it works with typescript! Here are some examples.
Your welcome @ ElVisPL @benjamindedonder.
@johnleider can we add this to the official documentation?
https://github.com/vuetifyjs/vuetify/issues/11388 Still doesn’t work when mocking
breakpoint