Skip to content

wrapper.find(ComponentName) fails if run after a test for that specific component #956

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
mkopinsky opened this issue Sep 5, 2018 · 3 comments
Labels

Comments

@mkopinsky
Copy link

mkopinsky commented Sep 5, 2018

Version

1.0.0-beta.24

Reproduction link

https://github.com/mkopinsky/vue-test-loading-order-issue

Steps to reproduce

git clone [email protected]:mkopinsky/vue-test-loading-order-issue.git
npm install
npm run test:passes # This runs Parent.test.js first, and passes
npm run test:fails # This runs Child.test.js first, and fails

What is expected?

Test outcomes should not depend on the order the tests run

What is actually happening?

If the test for the parent component is run before the test for the child component, everything is dandy.
If a test for the child component is run first, the test for the parent component fails with Error: [vue-test-utils]: find did not return Component, cannot call find() on empty Wrapper when I call wrapper.find(ChildComponent)

@eddyerburgh eddyerburgh added the bug label Sep 8, 2018
@eddyerburgh
Copy link
Member

Thank you for providing a good minimal reproduction.

The issue was a hangover from previous versions where we needed to remove cached constructors. Due to an internal change, this is no longer necessary, so I removed the code and added a test to make sure tests don't leak like this in the future. It will be released in the next beta version

@eddyerburgh
Copy link
Member

eddyerburgh commented Sep 8, 2018

For a quick fix, create the wrapper in the test function:

it('test', () => {
const wrapper = mount(Parent)
wrapper.find(Child)
})

@mkopinsky
Copy link
Author

Any chance you could release another beta with this fix (and other recent fixes)?

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