Mocking Vuex in Storybook and Vue Test Utils
tl;dr: Scroll down to Conclusion immediately
- In Storybook, each story is a new Vue app
⇒ register Vuex plugin on Vue prototype
- In Vue Test Utils, each test reuses the existing Vue constructor
⇒ register Vuex plugin on local Vue instance
In my current project assignment I have the honor to help 4 teams starting to improve code quality and to release more often. Unfortunately there are not a lot of dumb components, which are easier to test and to write stories for.
There is no safety net (tests + stories) created yet, so refactoring is kind of risky. The perfect Chicken and Egg problem! How can I still test these components? How do I mock the Vuex store?Read more →