831 questions
45
votes
4
answers
23k
views
Vue-Test-Utils Unknown custom element: <router-link>
I'm using Jest to run my tests utilizing the vue-test-utils library.
Even though I've added the VueRouter to the localVue instance, it says it can't actually find the router-link component. If the ...
10
votes
2
answers
3k
views
Unit testing in vuejs
I am trying to configure/run my first unit test for Vuejs. But I can't get past the configuration issues. I have tried installing the libraries but for some reason I keep getting errors.
Here is what ...
28
votes
4
answers
28k
views
How to test Vue watcher that watches a computed property from VueX?
Suppose I have the following component:
import { mapState } from 'vuex';
import externalDependency from '...';
export default {
name: 'Foo',
computed: {
...mapState(['bar'])
},
watch: {
...
17
votes
2
answers
21k
views
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 ...
0
votes
1
answer
2k
views
How to set data for the child vue component in vue-test-utils?
I have a FileForm.vue component:-
<template>
<div class="file-form">
<form @submit="submit">
<input v-model="name" type="text" placeholder="File Name" />
<...
3
votes
1
answer
5k
views
How do you test a Vue.js mixin's template?
So we have a Vue.js mixin which is inherited in individual components. The mixin has a template that is inherited by a handful of components and it works without problems. However, I can't work out ...
21
votes
3
answers
31k
views
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: {
...
11
votes
3
answers
4k
views
Testing a Vue component using element-ui component
I have a component that is using an element-ui component.
Tree.vue
<div>
<el-tree :data="treeData" :props="config"></el-tree>
</div>
I want to test the interactivity with ...
4
votes
1
answer
8k
views
how to mock i18next module in jest
I'm setting up test environment for existing Vue project, and I decided on jest with vue-test-utils.
Everything is installed and in place, however when I import component I wish to test in .test.js ...
0
votes
2
answers
909
views
DOM modification in mounted method not in JEST snapshot
I've got a Vue component and inside mounted method I have this:
this.el = d3.select(this.$el);
this.svg = this.el.select('svg')
.attr('width', mainSvgPos.svgWidth)
.attr('height', ...
2
votes
0
answers
151
views
Unable to trigger request on a subcomponent
I'm trying to add a test that could check a request sent from within vue-upload-component.
The request is sent when "Upload Files" button is clicked, the problem is that it's not triggered when I ...
13
votes
2
answers
5k
views
How to unit test Vue component that append DOM-element to HTML body?
I have a Vue 2.0 component that uses the Menu component from Vuetify. I'm using the official vue-test-utils to mount my component during test.
The problem I'm facing is that the Menu component append ...
2
votes
1
answer
3k
views
How do I test that a Vue component responds to an event emitted by $root?
I have a component that listens for an event emitted by the Vue $root instance.
export default {
data() {
return {
name: ''
}
},
methods: {
openModal(name) {
...
6
votes
5
answers
7k
views
How to unit test VueJS watcher on $route
I'm testing a Single file component that uses vue router to watch $route. The problem is that I can't get the test to both change the route and trigger the watcher's function.
The test file:
import ...
1
vote
2
answers
947
views
Cannot click on Vue Select Box using vue-test-utils
I can't seem to "click" on these select boxes using vue-test-utils and Vue 2. I am using mocha + webpack.
I am determining this by seeing that the visible-change event is never triggered as it should ...
0
votes
1
answer
289
views
mocha programmatically set vue error handler
I find myself writing this at the start of pretty much all of my unit tests in mocha:
it('should do something', (done) => {
Vue.config.errorHandler = done;
// do something aynchronous
});
By ...