Skip to content

Files

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Latest commit

97a8e5c · May 15, 2020

History

History
32 lines (21 loc) · 972 Bytes

setMethods.md

File metadata and controls

32 lines (21 loc) · 972 Bytes

setMethods

::: warning Deprecation warning setMethods is deprecated and will be removed in future releases.

There's no clear path to replace setMethods, because it really depends on your previous usage. It easily leads to flaky tests that rely on implementation details, which is discouraged.

Thus, we suggest to to rethink those tests using the tools Vue Test Utils provides. :::

Sets Wrapper vm methods and forces update.

Note the Wrapper must contain a Vue instance.

  • Arguments:

    • {Object} methods
  • Example:

import { mount } from '@vue/test-utils'
import sinon from 'sinon'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
const clickMethodStub = sinon.stub()

wrapper.setMethods({ clickMethod: clickMethodStub })
wrapper.find('button').trigger('click')
expect(clickMethodStub.called).toBe(true)