Skip to content
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

TypeError: Cannot read property 'devtoolsRawSetupState' of undefined #1329

Closed
jonsalvas opened this issue Feb 17, 2022 · 12 comments · Fixed by #1443
Closed

TypeError: Cannot read property 'devtoolsRawSetupState' of undefined #1329

jonsalvas opened this issue Feb 17, 2022 · 12 comments · Fixed by #1443
Labels
bug Something isn't working

Comments

@jonsalvas
Copy link

Vue Version: 3.2.31
Test-Utils: 2.0.0-rc.18

When upgrading from vue from 3.2.24 to 3.2.25 all our tests fail with the following error:

TypeError: Cannot read property 'devtoolsRawSetupState' of undefined

This is thrown when trying to call .findComponent on a mounted component using ref:
wrapper.findComponent({ref: ".."})

Seems that we were not alone with this issue:
vuejs/vue-test-utils#1962

@cexbrayat
Copy link
Member

@jonsalvas Thanks for the report. Can you provide a small reproduction so we can investigate? You can use create-vue to quickly set up a project with Vue Test Utils.

@lmiller1990
Copy link
Member

I guess we just need a check around this:

(vm.$ as unknown as { devtoolsRawSetupState: any }).devtoolsRawSetupState

We are on latest Vue here though, which is 3.2.31. I'd love to see a reproduction, too.

@jonsalvas
Copy link
Author

jonsalvas commented Feb 21, 2022

Hey, thanks for the fast reply and sorry for the delay, I had some other tasks to do at work. You can find a reproduction project here:
https://github.com/jonsalvas/test-utils-issue1329

I think the key is the v-for here:

<div v-for="value in 3" :key="value">
    <HelloWorld ref="hello" msg="Welcome to Your Vue.js App" />
  </div>

if I remove the v-for it works fine. So I highly assume a newer version of vue causes multiple refs with same name to be handled differently somehow?

@lmiller1990
Copy link
Member

lmiller1990 commented Feb 22, 2022

Is

<div v-for="value in 3" :key="value">

Even valid? I thought the syntax was v-for="val in {object|array}". Is using a number even documented or valid syntax? What if you make it v-for="val in [1,2,3]"?

@jonsalvas
Copy link
Author

The doc says the following are allowed: "Array | Object | number | string | Iterable" (https://vuejs.org/api/built-in-directives.html#v-for). And changing it to [1,2,3] makes no difference.

Anyway, the reproduction project is just a simplified example. In our original code we iterate over arrays of objects to generate multiple options/checkboxes.

@lmiller1990
Copy link
Member

Thanks for the repo, will try take a look.

@cexbrayat
Copy link
Member

I did not investigate but it looks similar to issues we've seen in vue core
vuejs/core#5118 should fix them upstream (and should be merged and released fairly soon).
I think that before spending too much time on this, we'll wait for this patch and revisit this to see if the issue persists.

@cexbrayat
Copy link
Member

@jonsalvas Can you give it a try with VTU 2.0.0-rc.20 and Vue v3.2.32 please? The fix I was talking about landed in Vue core, so it might solve your problem.

@jonsalvas
Copy link
Author

@cexbrayat nope, slightly different error, but technically the same:

TypeError: Cannot read properties of undefined (reading 'devtoolsRawSetupState')

@freakzlike
Copy link
Collaborator

I was able to reproduce it within our unit tests and created a PR with the fix.

@freakzlike freakzlike added bug Something isn't working and removed upstream labels Apr 19, 2022
@jonsalvas
Copy link
Author

thanks a lot! Any idea when it is going to be released?

@lmiller1990
Copy link
Member

thanks a lot! Any idea when it is going to be released?

It's out now! https://github.com/vuejs/test-utils/releases/tag/v2.0.0-rc.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants