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
It seems that v-text directives are ignored on child functional components when the parent component is mounted with shallowMount. I am using Vuetify but in this case, there should be no impact.
/* foo.spec.js */importVuefrom'vue'importVuetifyfrom'vuetify'import{createLocalVue,shallowMount}from'@vue/test-utils'importFoofrom'@/components/cards/Foo'Vue.use(Vuetify)constlocalVue=createLocalVue()describe('Foo.vue',()=>{it('should have a title',()=>{consttitle='My Title'constwrapper=shallowMount(Foo,{
localVue,vuetify: newVuetify({}),propsData: { title },})expect(wrapper.find('v-card-title-stub').text()).toBe(title)})})
Expected behaviour
Test should pass.
Actual behaviour
The test fail because the text inside stubed component v-card-title-stub is empty.
FAIL tests/unit/components/cards/foo.spec.js
● Foo.vue › should have a title
expect(received).toBe(expected) // Object.is equality
Expected: "My Title"
Received: ""
16 | propsData: { title },
17 | })
> 18 | expect(wrapper.find('v-card-title-stub').text()).toBe(title)
| ^
19 | })
20 | })
21 |
at Object.<anonymous> (tests/unit/components/cards/foo.spec.js:18:54)
Possible Solution
If I use mustache interpolation instead, the test works fine.
<template><v-card><v-card-title>{{ title }}</v-card-title></v-card></template>
I don't know vue-test-utils library but, I think the bug is in createStubFromComponent function (create-component-stubs.js). The domProps in the context.data is never passed.
To try, I added a line to keep domProps as a ref and everything seems to work. I don't know if this is the good solution.
…1697)
a child functional component must display content of v-text directive when it is mounted with
shallowMount
fix#1693
Co-authored-by: Jeremy Cassou <[email protected]>
Subject of the issue
It seems that v-text directives are ignored on child functional components when the parent component is mounted with shallowMount. I am using Vuetify but in this case, there should be no impact.
Steps to reproduce
Expected behaviour
Test should pass.
Actual behaviour
The test fail because the text inside stubed component v-card-title-stub is empty.
Possible Solution
If I use mustache interpolation instead, the test works fine.
I don't know vue-test-utils library but, I think the bug is in createStubFromComponent function (create-component-stubs.js). The domProps in the context.data is never passed.
To try, I added a line to keep domProps as a ref and everything seems to work. I don't know if this is the good solution.
The text was updated successfully, but these errors were encountered: