Skip to content

Can't test props on child component when it's the root element #1241

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
alexanderstudte opened this issue May 22, 2019 · 4 comments
Closed

Comments

@alexanderstudte
Copy link

alexanderstudte commented May 22, 2019

Version

1.0.0-beta.29

Reproduction link

https://github.com/alexanderstudte/propsdatatest

Steps to reproduce

run the unit test as is -> test fails.
add empty <div> around the <Panel> in HelloWorld.vue and run the test again -> test successful

What is expected?

I should be able to test the props from the child component if it is root

What is actually happening?

I need to add an element around the child for it to be no longer root.

@fgordillo
Copy link

It's also failing for me and adding a wrapping div to the component is also making the test pass. In my case, I have a presenter component inside a wrapper component. The wrapper component is listening to the events sent by the presenter component. I'm able to test that the event has been triggered, but the methods bound to the event are never called.

@andrewdavidcostello
Copy link

Came across this issue today also, the workaround I am using is to access the children.

expect(wrapper.find('some-stub-name').vm.$children[0].$props.somepropname).toStrictEqual(somepropvalue);

@nanditsaini
Copy link

nanditsaini commented Jan 29, 2020

I am also facing the same issue and actually I observed one more thing that when I am using wrapper.props() method it gives the component's(the one which I am writing test cases of) props and when I use wrapper.attribues() I get the props of the root child component.

@ebisbe ebisbe added the bug label Jan 27, 2023
@ebisbe
Copy link
Collaborator

ebisbe commented Feb 15, 2023

#1564 (comment)

@ebisbe ebisbe closed this as completed Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants