-
Notifications
You must be signed in to change notification settings - Fork 669
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 '$options' of undefined #673
Comments
Thanks for the bug report. This is the same issue filed here—#653. This is a problem with how we have implemented synchronous updating. There's a PR open to fix this by adding an async option to Vue—vuejs/vue#8240. For the moment, the workaround is to set the test('use Vue.nextTick', (done) => {
const wrapper = mount(TestComponent, { sync: false })
wrapper.trigger('click')
Vue.nextTick(() => {
expect(wrapper.text()).toBe('updated')
done()
})
}) |
I ran into this issue myself. However, I couldn't get Edd Yerburgh solution to work for me. I was working with a form submit trigger event.
test('use Vue.nextTick', async () => {
const wrapper = mount(TestComponent, { sync: false })
wrapper.trigger('submit')
await flushPromises()
expect(wrapper.text()).toBe('updated')
}) UpdateMy above example actually didn't work as expected. Here is what I changed. test('use Vue.nextTick', async () => {
const wrapper = mount(TestComponent, { sync: false })
wrapper.trigger('submit')
await wrapper.vm.$nextTick()
expect(wrapper.text()).toBe('updated')
}) |
@nathanjisaac thanks men this is huge serve ! |
I've updated to @vue/test-utils 1.0.0-beta.29 and vue 2.5.22 and I've the same issue. I pulled out a minimal reproduction on https://github.com/rndmerle/repro-vue-test-utils-sync.git The test would pass if you change either one of those:
I can't find anything further down, my brain is boiling. |
Yea but I thought #1062 would solve that somehow. I misunderstood something I guess. |
We were hoping #1062 would be a medium-term solution, but there are lots of edge cases we didn't anticipate. |
It's clearer now thanks ;) |
Version
1.0.0-beta.15
Reproduction link
https://github.com/feliupe/vuerror
Steps to reproduce
yarn && yarn test
What is expected?
The test to run with no error.
What is actually happening?
There two errors:
TypeError: Cannot read property '$options' of undefined
TypeError: Cannot set property '_error' of undefined
, that I think is related to the errorHandler and my not be related to the test failing.I tried to create the minimum setup to reproduce the problem. Almost any statement you remove from this code will make the test pass. Like removing
<message/>
for example.You may ask, why this setup of components, with a
Tree
andMessage
wrapped in aLayout
: it's a representation of what I have in my project.May also help to know that the error disappears if you remove
wrapper.vm.treeData = {}
and also happens if you uncommentwrapper.vm.$forceUpdate()
.The text was updated successfully, but these errors were encountered: