diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /doc/development/testing_guide/testing_levels.md | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'doc/development/testing_guide/testing_levels.md')
-rw-r--r-- | doc/development/testing_guide/testing_levels.md | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/doc/development/testing_guide/testing_levels.md b/doc/development/testing_guide/testing_levels.md index 480a53bbefe..4e4dc671c03 100644 --- a/doc/development/testing_guide/testing_levels.md +++ b/doc/development/testing_guide/testing_levels.md @@ -197,16 +197,8 @@ graph RL #### What to mock in component tests -- **DOM**: - Operating on the real DOM is significantly slower than on the virtual DOM. -- **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. +- **Side effects**: + Anything that can change external state (for example, a network request) should be mocked. - **Child components**: Every component is tested individually, so child components are mocked. See also [`shallowMount()`](https://v1.test-utils.vuejs.org/api/#shallowmount) @@ -215,8 +207,10 @@ graph RL - **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. -- **Functions and classes independent from Vue**: - All plain JavaScript code is already covered by unit tests and needs not to be mocked in component tests. +- **Vuex**: + Keep Vuex unmocked to avoid fragile and false-positive tests. + Set the Vuex to a proper state using mutations. + Mock the side-effects, not the Vuex actions. ## Integration tests |