[Vuejs]-Mocking/Testing Vuex store modules is giving me TypeError problems

0👍

The answer is because you are mocking the $store property on your component, but you aren’t using that way in your component. Your component is using the ...mapState() method, which will automatically expect that a Vuex.Store() was instantiated on a local copy of Vue. Take a look at the following link to properly mock up a Store for a local component’s unit / integration test(s):

https://vue-test-utils.vuejs.org/guides/using-with-vuex.html

Quick shoutout to @Anatoly, who provided the link.

Leave a comment