-
Notifications
You must be signed in to change notification settings - Fork 6
Automated Testing (Vue)
We want to individually test the following pieces of the MyUW front-end:
- Vuex Stores
- Vue Mixins
- Vue Plugins
- Vue Components
Use faker to create mock data generator specific to the vuex store. This generator will be used to generate data for axios.get
mocks.
- Mock
axios.*
- Set the initial state if needed
- Execute the action
- Test for
axios.*
method calls - Insure the final state is correct
- Set the initial state
- Insure the getter return value is correct
- Import the mixin and test the method though
<mixin>.methods.<method>
- Create a Vuex instance with the required state
- Test the method / computed through
<Vuex instance>.<method / computed>
Testing each plugin is unique. In general all variables exposed, all directives defined, and all lifecycle hooks used by the plugin need to be tested.
Component testing should not use the vuex stores but instead should use a mocked version. These mocks should use the postProcess
method from the real store when necessary. They can reuse the mock data generator created in Testing Vuex Stores > Generating Mock data. The main reason to use a mocked store is to make it easier to override the return values from each store.
- Create the required localVue and Vuex store.
- Test all the methods / computed fields defined in the component.
Mount the component using @cypress/vue and then go through all user workflows.