How to test Vue watcher that watches a computed property from VueX?

后端 未结 4 1760
一个人的身影
一个人的身影 2021-02-12 12:53

Suppose I have the following component:

import { mapState } from \'vuex\';
import externalDependency from \'...\';

export default {
  name: \'Foo\',
  computed:         


        
4条回答
  •  名媛妹妹
    2021-02-12 13:19

    You will need some sort of mutator on the VueX instance, yes this does introduce another unrelated unit to the test but personally by your test including the use of Vuex, that concept has already been broken.

    Modifying the state in an unexpected way is more prone to cause behaviour that differs from the actual usage.

提交回复
热议问题