This cook book is a collection of recipes applying unit testing to real world VueJs applications.
- Understanding of unit testing
- Experience with VueJs
- Experience with Vue-test-utils
Vue-test-utils is the core libary that enables unit tesing of Vue applications. Please follow the best practises documented on Vue-test-utils website.
Vue-test-utils-helper library provides helper functions for mocking components, Vuex and Vue Router.
In computer programming, unit testing is a software testing method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use. wikipedia
In VueJs world the units that we test are:
- Components (including Views)
- Directives
- Functions (filters, services, utilities)
- Store modules
- How to mount a component
- Handling Vuex
- Handling Vue Router
- Project specific mount function
- Recipe: Unit test a component with no child components
- Recipe: Unit test a component with child components
- Recipe: Unit test component with keup event
- Recipe: Unit test component with router link
- Recipe: Unit test navigation to a specific route