On the last section, we started to test Vuex stores. More precisely we tested the “mutations” and the “getters”. Now let’s focus on the last part of the store; the “actions”.

“Actions” are a bit less straightforward to test than “mutations” and “getters”. By essence, they contain more complex operations; like calling external APIs, calling several commits or actions, and they are promised based. This requires more complex and advanced features of Jest.

Testing an action

Calling an “action” in test context is similar to calling “mutations” and “getters”. There is a slight difference, there is a need to cast the call as…

CODEX

Photo by Markus Spiske on Unsplash

This tutorial is focused on testing a VueJS app using TypeScript. We will be using Jest (the TypeScript version “ts-jest”).

I will be using an open-source app I developed called LEMU. A quick word about it; it is a graphical application to manage BackstopJS visual regression tests. This app has been created with the Vue CLI with a TypeScript configuration along with Jest as a unit test framework.

But let’s get started. We will cover unit testing an application. Unit testing is covering the smallest unit of your software: a function. A unit test should cover every single case possible…

Vincent Francolin

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store