Questions tagged [vue-test-utils]

Helpers to render VueJS components in unit tests.

Toolset to make complete or shallow rendering VueJS components while writing unit tests. Can be run under Jest or Mocha test runners. See vue-test-utils.vuejs.org for details.

814 questions
18
votes
3 answers

How do you set the data values in a component with Vue-Test-Utils before mounted is called?

I am using Jest with Vue-Test-Utils. The code I have been using looks like this: beforeEach(() => { wrapper = shallow(GridContainer, { data: { pageSize: count }, propsData: { userId, managerId } }) }) In this…
Daryn
  • 3,394
  • 5
  • 30
  • 41
17
votes
2 answers

What are "stubbed child components" in Vue Test Utils?

Vue Test Utils has an API method called shallowMount() that: ...creates a Wrapper that contains the mounted and rendered Vue component, but with stubbed child components. I've searched the Vue Test Utils documentation website but failed to find a…
urig
  • 16,016
  • 26
  • 115
  • 184
17
votes
2 answers

How can I test a custom input Vue component

In the Vue.js documentation, there is an example of a custom input component. I'm trying to figure out how I can write a unit test for a component like that. Usage of the component would look like this
Jason Desrosiers
  • 22,479
  • 5
  • 47
  • 53
16
votes
5 answers

vue-test-utils: could not overwrite property $route, this is usually caused by a plugin that has added the property as a read-only value

I've looked at other answers with this problem, and it seems to be caused by trying to import vue-router into the test. This however, is not the case for my problem. Here is my test code: import { mount, shallowMount, createLocalVue } from…
janedoe
  • 907
  • 1
  • 13
  • 33
15
votes
3 answers

Testing with `Created` hook with `vue-test-utils` and `jest`

I have a Vue page like this: Now, we want to the testing of this created hook and check that doSomething() method…
Neeladri Rudra
  • 151
  • 1
  • 1
  • 4
15
votes
1 answer

Trigger form submit on button click in Vue Unit Test

Is there a way to actually trigger the submission of a form by clicking on a submit button in a Vue Unit Test? Let's take this simple component: