Skip to content

Children incorrectly rendered as false #857

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
moizang opened this issue Jul 27, 2018 · 1 comment
Closed

Children incorrectly rendered as false #857

moizang opened this issue Jul 27, 2018 · 1 comment
Labels

Comments

@moizang
Copy link

moizang commented Jul 27, 2018

Version

1.0.0-beta.21

Reproduction link

https://codesandbox.io/s/wnvpvr97ow

Steps to reproduce

Using Vuetify, I'm trying to test my usage of v-components :

Snapshots :

  • No matter what I set between two v-component tags, it's always rendered as false in my snapshot when I shallowMount my component

wrapper.find() doesn't seem to work on Vuetify components :

  • Creating a component with a template featuring a v-component with a class prop set to "something"

  • shallowMounting the new component

  • Trying to perform a wrapper.find('.something') on my component

What is expected?

  • Snapshot of v-component -> expecting to see the values / or other components I used in my template between the v-component-stub tags

  • wrapper.find('.v-component_class') -> New wrapper with v-component

What is actually happening?

  • Snapshot : Always get false value between v-component stub tags

  • wrapper.find('.v-component_class') -> empty wrapper


Both seemed to work in 1.0.0-beta.20

@eddyerburgh eddyerburgh changed the title Vuetify components testing issues Children incorrectly rendered as false Jul 28, 2018
@eddyerburgh
Copy link
Member

The problem with the child rendering false was because we were not handling functional components in the stub. I've fixed that in #860 .

The second problem you have is because you're using shallowMount instead of mount. shallowMount stubs all child components to render as a tag with the name ${registerd-component-name}-stub . You can solve it by using mount:

const wrapper = mount(TestComponent, { localVue });
const iconStyle = wrapper.find("icon-stub").element.style.color;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants