You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/guides/using-with-vuex.md
+5-6
Original file line number
Diff line number
Diff line change
@@ -109,7 +109,7 @@ The most important thing to note in this test is that **we create a mock Vuex st
109
109
110
110
Great, so now we can mock actions, let’s look at mocking getters.
111
111
112
-
## Mocking Getters
112
+
###Mocking Getters
113
113
114
114
115
115
```html
@@ -178,7 +178,7 @@ This test is similar to our actions test. We create a mock store before each tes
178
178
179
179
This is great, but what if we want to check our getters are returning the correct part of our state?
180
180
181
-
## Mocking with Modules
181
+
###Mocking with Modules
182
182
183
183
[Modules](https://vuex.vuejs.org/en/modules.html) are useful for separating out our store into manageable chunks. They also export getters. We can use these in our tests.
184
184
@@ -274,7 +274,6 @@ export default {
274
274
state.count++
275
275
}
276
276
}
277
-
278
277
```
279
278
280
279
```js
@@ -286,7 +285,7 @@ export default {
286
285
287
286
### Testing getters, mutations, and actions separately
288
287
289
-
Getters, mutations, and actions are all JavaScript functions, so we can test them without using `vue-test-utils`or Vuex.
288
+
Getters, mutations, and actions are all JavaScript functions, so we can test them without using `vue-test-utils`and Vuex.
290
289
291
290
The benefit to testing getters, mutations, and actions separately is that your unit tests are detailed. When they fail, you know exactly what is wrong with your code. The downside is that you will need to mock Vuex funtions, like `commit` and `dispatch`. This can lead to a situation where your unit tests pass, but your production code fails because your mocks are incorrect.
292
291
@@ -333,7 +332,7 @@ test('evenOrOdd returns odd if state.count is even', () => {
333
332
334
333
### Testing a running store
335
334
336
-
Anopther approach to testing a Vuex store is to create a running store using the store config.
335
+
Another approach to testing a Vuex store is to create a running store using the store config.
337
336
338
337
The benefit of testing creating a running store instance is we don't have to mock any Vuex functions.
339
338
@@ -383,7 +382,7 @@ test('updates evenOrOdd getter when increment is commited', () => {
383
382
384
383
Notice that we use `cloneDeep` to clone the store config before creating a store with it. This is because Vuex mutates the options object used to create the store. To make sure we have a clean store in each test, we need to clone the `storeConfig` object.
385
384
386
-
###Resources
385
+
## Resources
387
386
388
387
-[Example project for testing the components](https://github.com/eddyerburgh/vue-test-utils-vuex-example)
389
388
-[Example project for testing the store](https://github.com/eddyerburgh/testing-vuex-store-example)
0 commit comments