Skip to content
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

wrapper.find() hasn't access to template #1

Open
verget opened this issue Jul 11, 2019 · 1 comment
Open

wrapper.find() hasn't access to template #1

verget opened this issue Jul 11, 2019 · 1 comment

Comments

@verget
Copy link

verget commented Jul 11, 2019

For testing purpose, I try to trigger an event on some html element inside my component for check if my vuex action triggered. In my .spec file I try this:

import Component from '../../../src/components/component'

localVue.use(Vuex)

describe('Component', () => {

  beforeEach(() => {
    actions = {
      actionClick: jest.fn()
    }
    store = new Vuex.Store({
      state: {},
      actions
     })
  })

  it('trigget "actionClick" by button click', () => {
    const wrapper = shallowMount(Component, { store, localVue })
    wrapper.find('button').trigger('click')
    expect(actions.actionClick).toHaveBeenCalled()
  })
})

Template is simple:
<button @click="triggerClick">test</button>

But I have nothing except
[vue-test-utils]: find did not return button, cannot call trigger() on empty Wrapper
Did I miss something?

@tflori
Copy link
Owner

tflori commented Jul 15, 2019

this library is just for testing separated templates of typescript components. Have you tried this with an inline template like it is described here?

Have you tried to get wrapper.html() to see if it loads the template? And does it work when you build the application.

The signature of the component would be great. Maybe there I can see what is wrong...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants