Skip to content

Trigger disregards setMethods and remains referencing the old one #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lchanmann opened this issue May 15, 2018 · 0 comments · Fixed by #622
Closed

Trigger disregards setMethods and remains referencing the old one #615

lchanmann opened this issue May 15, 2018 · 0 comments · Fixed by #622
Labels

Comments

@lchanmann
Copy link
Contributor

Version

1.0.0-beta.16

Reproduction link

https://github.com/lchanmann/vue-test-utils-setMethods-issue

Steps to reproduce

Clone the repo, then run:

yarn install
yarn test

What is expected?

Should pass tests

What is actually happening?

Test fails

FAIL  ./setMethods.test.js
 ● Console

   console.log setMethods.test.js:9
     clickMethod

 ● setMethods › calls stub when event is triggered

   expect(jest.fn()).toHaveBeenCalled()

   Expected mock function to have been called.

     at Object.<anonymous> (setMethods.test.js:17:29)
         at new Promise (<anonymous>)
         at <anonymous>
     at process._tickCallback (internal/process/next_tick.js:188:7)

setMethods.test.js

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

describe('setMethods', () => {
  it('calls stub when event is triggered', () => {
    const TestComponent = {
      template: '<button @click="clickMethod">Click here</button>',
      methods: {
        clickMethod() {
          console.log('clickMethod')
        }
      }
    }
    const wrapper = mount(TestComponent)
    const clickMethodStub = jest.fn()
    wrapper.setMethods({ clickMethod: clickMethodStub })
    wrapper.find('button').trigger('click')
    expect(clickMethodStub).toHaveBeenCalled()
  })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants