Closed Prior99 closed 6 years ago
This doesn't look related to vue core. If you think it is please remove all the other dependencies from the repro. You may want to open an issue in vue-test-utils instead of vuex if the error only happens in test environment
@posva I think that this bug is indeed related to vue core as it is vue which handles calling the beforeCreate
hook. What kind of environment is required so that you will accept the bug report?
The minimal possible, so no test environment, no external libraries. It can be in a jsfiddle (http://jsfiddle.net/posva/wsr78d2w/). ~But I took a look at your code and you are trying to access a non-existant property $content
so it's normal to have that error~
@posva Please take a look at the actual unit test and my issue description. The $content
property is set in the beforeCreate
hook in line 8.
Indeed! Ignore that 🙂
I created an issue in vue-test-utils now as I suppose this might be related to how they mount the components. I still suspect vue core to be the underlying problem, however I guess it'd be better to first eliminate the test utilities to be the problem.
I can confirm that the problem is with Vue Test Utils, and how components extend from the localVue constructor
Versions
Reproduction link
https://github.com/hwestphal/vue-crash-reproduce
Steps to reproduce
yarn
yarn test
What is expected?
The unit tests should pass with no errors.
What is actually happening?
The unit test fails because the value which is added to the component in the unit test
is accessed in the component in
which makes the test fail with
However, when deleting the access in the component, the asserts in the test:
pass which leads to the conclusion that after the
mount(ParentComponent, { localVue })
the hook is called while it wasn't during the mount.When removing the
Vue.extend(...)
around theSomeComponent
insrc/some-component.vue
the error disappears and everything worsk fine.Hints
This issue might be related to vue-test-utils instead. I had a look at whether vue-jest could be related to this issue but it doesn't seem to.
This issue might be the underlying issue for vuex#1330.