Operating on the real DOM is significantly slower than on the virtual DOM.
Anything that can change external state (for example, a network request) should be mocked.
-**Properties and state of the component under test**:
Similar to testing classes, modifying the properties directly (rather than relying on methods of the component) avoids side effects.
-**Vuex store**:
To avoid side effects and keep component tests simple, Vuex stores are replaced with mocks.
-**All server requests**:
Similar to unit tests, when running component tests, the backend may not be reachable, so all outgoing requests need to be mocked.
-**Asynchronous background operations**:
Similar to unit tests, background operations cannot be stopped or waited on. This means they continue running in the following tests and cause side effects.
-**Child components**:
-**Child components**:
Every component is tested individually, so child components are mocked.
Every component is tested individually, so child components are mocked.
See also [`shallowMount()`](https://v1.test-utils.vuejs.org/api/#shallowmount)
See also [`shallowMount()`](https://v1.test-utils.vuejs.org/api/#shallowmount)
...
@@ -215,8 +207,10 @@ graph RL
...
@@ -215,8 +207,10 @@ graph RL
-**Methods or computed properties of the component under test**:
-**Methods or computed properties of the component under test**:
By mocking part of the component under test, the mocks are tested and not the real component.
By mocking part of the component under test, the mocks are tested and not the real component.
-**Functions and classes independent from Vue**:
-**Vuex**:
All plain JavaScript code is already covered by unit tests and needs not to be mocked in component tests.
Keep Vuex unmocked to avoid fragile and false-positive tests.