Reputation: 702
I am changing vuex state value using commit in my tests and then trying to see whether element that supposed to be rendered based on the change is present. Something like this
it('should render error state if no stores', () => {
wrapper.store.commit('stores/updateLoadingStores', false);
wrapper.store.commit('stores/updateStores', []);
expect(wrapper.find('error-state-stub').exists()).toBe(true);
});
Instead I am getting next error ``` StoresStep › should render error state if no stores
TypeError: Cannot read property '_isDestroyed' of undefined
31 | const mutationName = `${prefix}${_upperFirst(name)}`;
32 | acc[mutationName] = (state, value) => {
> 33 | state[name] = value;
| ^
34 | };
35 | return acc;
36 | }, {});
at destroy (node_modules/vue/dist/vue.runtime.common.dev.js:3151:28)
at invokeDestroyHook (node_modules/vue/dist/vue.runtime.common.dev.js:6088:59)
...
```
The function it complains about is a wrapper to set value to specific module.
See actual error - TypeError: Cannot read property '_isDestroyed' of undefined
which is coming from vue.runtime.common.dev.js
I thought it is Vue.$nextTick() related but seems like no.
wrapper.store
part is just util I wrote to be able to mount component and use everything related to it in one place.
Will appreciate any help.
Upvotes: 1
Views: 1063
Reputation: 702
Finally I figured it out. The problem was not obvious. I had to dig through vue.js source code to find a clue to the original issue. Basically, this vue-test-utils issue partially explains it - https://github.com/vuejs/vue-test-utils/issues/52
The biggest problem was that error doesn't link you to transitions at all, so I was looking in the wrong direction.
And the solution is simple, just stub transition :)
VueTestUtils.config.stubs['transition'] = true;
Upvotes: 1