I have a vue code where i do some actions based on this.$refs.form.validate I wanted to write a test for it ...But not sure how can i mock this.$refs.form.validate? I have written only basic ones..can someone point me at right direction?I am using Vue+Jest
methods: {
        sayHello () {
          if (this.$refs.form.validate()) {
            //code goes here
    }
Is there a way to make it return false and true?
create a stub
const VueFormStub = {
 render: () => {},
 methods: {
  validate: () => {}
 }
}
then in your wrapper add it like this
const wrapper = shallowMount(VueFile, {
 stubs: {
  'v-form': VueFormStub
 }
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With