diff options
author | Dennis Tang <dennis@dennistang.net> | 2018-05-08 17:55:49 +0300 |
---|---|---|
committer | Dennis Tang <dennis@dennistang.net> | 2018-05-08 17:55:49 +0300 |
commit | 7e0af6cfc9d9d0272f3b29f128a37863bd6e6324 (patch) | |
tree | 997c795d1d747256131b20cc98684dee204aab6c /doc/development/fe_guide/vuex.md | |
parent | 6fd75502d6afed374bf34f193b44eac57bf5ba33 (diff) |
add rewire gotcha about testing vuex actions/getters
Diffstat (limited to 'doc/development/fe_guide/vuex.md')
-rw-r--r-- | doc/development/fe_guide/vuex.md | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/development/fe_guide/vuex.md b/doc/development/fe_guide/vuex.md index d6305bc4dec..29d5e446e20 100644 --- a/doc/development/fe_guide/vuex.md +++ b/doc/development/fe_guide/vuex.md @@ -352,6 +352,18 @@ describe('component', () => { }); ``` +#### Testing Vuex actions and getters +Because we're currently using `babel-plugin-rewire`, you may encounter the following error when testing your Vuex actions and getters: +`[vuex] actions should be function or object with "handler" function` + +To prevent this error from happening, you need to export an empty function: +``` +// /stores/getters.js or /stores/actions.js + +// prevent babel-plugin-rewire from generating an invalid default during karma tests +export default () => {}; +``` + [vuex-docs]: https://vuex.vuejs.org [vuex-structure]: https://vuex.vuejs.org/en/structure.html [vuex-mutations]: https://vuex.vuejs.org/en/mutations.html |