Mirza Ahmed
Mirza Ahmed

Reputation: 51

VueJS - jest: How to test/spy the methods which are getting called inside the watcher?

Sample Code from the VueJs components. Note that I'm trying to cover the watcher as well as the method

computed: {
              ...mapGetters({
               resourceLinks: `tools/${storeGetters.resourceLinks}`,
            }),
        },
        methods: {
              formatData(data) {
                this.setSocialLinks();
            },
        },
    },
        watch: {
            resourceLinks(data) {
                this.formatData(data);
            },
        },

Upvotes: 2

Views: 945

Answers (1)

Mirza Ahmed
Mirza Ahmed

Reputation: 51

expect(wrapper.vm.$options.watch.resourceLinks.call(wrapper.vm, resourceLinks1));

Upvotes: 2

Related Questions