You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I would like to add vuetify to vue before rending a component that uses vuetify components, so that the render is successful
To Reproduce
create a component that uses <v-btn>Ok</v-btn>, making sure it renders correctly in browser (follow vuetify instructions)
write unit test for it. Classic example using the vue/testing-utils:
import { createLocalVue, mount, shallowMount } from '@vue/test-utils'
import Home from '@/components/Home.vue'
import vuetify from "vuetify"
describe('Home.vue', () => {
let wrapper;
let title = 'Weather App'
beforeEach(()=>{
const localVue = createLocalVue()
localVue.use(vuetify)
wrapper = shallowMount(Home, {
localVue // this is important
});
})
vuew/test-utils exposes createLocalVue, which testing library is not using. There is no way to pass localVue to the "render" method of testing-library.
unit test code using the testing-library
import { render, fireEvent } from '@testing-library/vue'
// import { createLocalVue} from '@vue/test-utils'
import UserForm from "@/components/UserForm.vue";
// import vuetify from "vuetify"
test('properly handles v-model', async () => {
// const localVue = createLocalVue()
// localVue.use(vuetify)
const { getByLabelText, getByText } = render(UserForm) // no way to pass "localVue"
..
})
fails with
console.error node_modules/vue/dist/vue.runtime.common.dev.js:621
[Vue warn]: Unknown custom element: <v-btn> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Expected behavior
Should be able to load vuetify to the vue before rending a component.
Related information:
@testing-library/vue version: 4.1.0
Vue version: 2.6.10
node version: 11.x
npm (or yarn) version:
The text was updated successfully, but these errors were encountered:
@afontcu I have the problem that with your example, child components of the tested component don't have access to store anymore. For them it is undefined. Any idea how to fix?
Describe the bug
I would like to add
vuetify
to vue before rending a component that uses vuetify components, so that the render is successfulTo Reproduce
<v-btn>Ok</v-btn>
, making sure it renders correctly in browser (follow vuetify instructions)vuew/test-utils exposes createLocalVue, which testing library is not using. There is no way to pass localVue to the "render" method of testing-library.
fails with
Expected behavior
Should be able to load vuetify to the vue before rending a component.
Related information:
@testing-library/vue
version: 4.1.0Vue
version: 2.6.10node
version: 11.xnpm
(oryarn
) version:The text was updated successfully, but these errors were encountered: