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/testing.md
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -128,6 +128,24 @@ describe('actions', () => {
128
128
})
129
129
```
130
130
131
+
If you have spies available in your testing environment (for example via [Sinon.JS](http://sinonjs.org/)), you can use them instead of the `testAction` helper:
132
+
133
+
```js
134
+
describe('actions', () => {
135
+
it('getAllProducts', () => {
136
+
constcommit=sinon.spy()
137
+
conststate= {}
138
+
139
+
actions.getAllProducts({ commit, state })
140
+
141
+
expect(commit.args).to.deep.equal([
142
+
[ 'REQUEST_PRODUCTS' ],
143
+
[ 'RECEIVE_PRODUCTS', { /* mocked response */ } ]
144
+
])
145
+
})
146
+
})
147
+
```
148
+
131
149
### Testing Getters
132
150
133
151
If your getters have complicated computation, it is worth testing them. Getters are also very straightforward to test as same reason as mutations.
0 commit comments