Save time setting up unit testing of vue apps that integrate vuetify and vuex.
I am not completely convinced of the value in unit testing vue applications, yet. Cypress end-to-end tests tend to catch the difficult to find bugs lurching at the integration points better. But, time will tell how I divide the testing between vue test utils and cypress.
The Project setup
The Testing setup
- vue test utils
- jest test runner
I had already written a proof of concept project when I tried to add the unit tests. But whenever I wrote a test, I would get the error below. So, I decided to start a new project following the ‘Step by Step Guide’ by Dávid Gergely referenced below. I finally discovered I needed to add a store to my unit test in order to get the test to run. See below for more details on the challenge and solution.
The unit test would blow up with the following error.
The error was fixed by declaring a store with modules in the beforeEach test block. Then, passing that store into the shallowMount command that sets up the wrapper.
Let’s have a conversation!
What kind of testing do you finding valuable? I am super interested in leveling up my Vue testing.
Please check in with me on twitter. My Twitter handle is @ardith_falkner.