831 questions
2
votes
0
answers
1k
views
Vitest & Vue-Test-Utils Testing Function
I want to test that the function is called in a simple project.
For this, I read the documentation of Vitest - Function and tried to write test as below.
However, I keep getting an error that the ...
1
vote
0
answers
31
views
missing param for named route "x"
I am trying to test this code:
template(#item.id='props')
router-link(:to='{ name:"ticketDetail", params: { ticketId: props.item.shortId }}')
| {{ props.item.shortId }}
...
7
votes
0
answers
4k
views
[Vue warn]: Error in data(): "TypeError: Cannot destructure property 'store' of '(0 , _compositionApi.useContext)(...)' as it is undefined."
I am setting up tests on a Nuxt2 app using @nuxtjs/composition-api and
@vue/test-utils.
In addition, there is a vue-CLI UI library using @vue/composition-api and vue-demi.
The issue is that even if ...
0
votes
0
answers
299
views
Is there any way to test a function in jest + vue-test-utils after async/await promise?
Helloo!
i'm trying to cover 100% of my file with unit tests, but I can't test a function in onMounted() that is called after a async/await promise.
using Vue3, Pinia, i18n, Jest and Vue-test-utils.
I ...
0
votes
0
answers
181
views
Asserting whether a method has been called in the created lifecycle hook
I'm writing a test using Jest for a Vue application. Now I'm trying to assert whether a certain method is being called when the component is created. For some reason I'm getting back that the method ...
0
votes
1
answer
295
views
How to test methods imported from other components or JS file
I don´t have much experience with unit testing.
What is the proper way to test a method imported from a JS file or from another component?
This is a sample component I created a localSum just to use ...
2
votes
0
answers
950
views
Cannot read properties of undefined (reading 'deep') when mount function from "vue/test-utils" is called with a Vue component
DESCRIPTION
Hello! I'm working in a quasar project migrating from jest to vitest and my old test were working perfectly, but when i installed vitest one of those test failed even after refactor... It ...
0
votes
1
answer
105
views
error detecting global http method from vue test
I'm running vue3 and testing a vue component using the vue test utils library and in the component i am making an api call like this:
const api = this.$http.publisher.fetchValidatedWebsites();
I ...
1
vote
1
answer
598
views
Test if imported method is called
I'm trying to test if a composable's method is called from my store. Here's what I have:
/stores/ui:
import { defineStore } from 'pinia';
import { useUtils } from '@/composables/utils';
const { ...
1
vote
1
answer
578
views
Error in mounted hook: "TypeError: this.$refs.modal.open is not a function"
I have this component:
export default class ModalDetails extends Vue {
mounted(): void {
(this.$refs.modal as any).open();
}
}
which I am trying to test:
describe('ModalDetails', () => ...
1
vote
0
answers
109
views
Cannot find module '~/utility/functions' from 'Compnent.vue'
I'm runing unit test for vue files. in the vue component i have imported ~/utility/functions file it worked in vue but while testing im getting
Cannot find module '~/utility/functions' from 'Compnent....
1
vote
0
answers
120
views
vue custom filter error in vue test utils
I am getting this error when running my test in vue-test-utils this.$options.filters.customCurrency is not a function
How can I either stub this as it's not needed or mock the function to prevent the ...
0
votes
2
answers
1k
views
Vue test utils: extend VueWrapper to add plugin method
I am using Vue test utils and Typescript. I have added Data Test ID Plugin.
How can I extend VueWrapper interface to avoid this error:
Property 'findByTestId' does not exist on type 'VueWrapper<{ $:...
0
votes
1
answer
2k
views
Cannot mount TipTap content in Vitest unit test
I have a vue component that contains a TipTap editor, which I am having problems testing. I am using Vitest with vue-test-utils.
This is my component:
<script setup lang="ts">
import { ...
4
votes
2
answers
3k
views
How to mock Nuxt's useLazyFetch method with Vitest
I'm trying to mock a call of Nuxt's useLazyFetch() method and let it respond with a .json fixture in a test. The stack I'm using is as follows:
vitest 0.22.1
@vue/test-utils 2.0.2
Nuxt 3.0.0-rc.6
...
2
votes
1
answer
14k
views
Vuejs unit tests: Cannot call text on an empty DOMWrapper
I'm using vue test utils to test a component and getting this error trying to test a text. Cannot call text on an empty DOMWrapper.
UPDATED CODE.
getting " RangeError: Maximum call stack size ...
0
votes
1
answer
316
views
How to use html() and toContain() with shallowMount in Vue with some div containing another component?
I have problem with shallowMount in Vue.
My function looks like this:
describe('ParentComponent.vue', () => {
it('renders a ParentComponent', () => {
const wrapper = shallowMount(...
2
votes
0
answers
423
views
How can I test nested slots in Vue
I am trying to pass nested slots into my mounted component and I can;'t figure out the syntax, couldn't find anything in docs.
What I am trying to do is to add html element into drop-down slot
This is ...
4
votes
2
answers
3k
views
How to mock a function/method in Vue 3 with Vue Test Utils 2?
I am in the process of converting my project from Vue 2 to 3 and also testing library to Vue test utils 2. Before, mocking methods works like magic:
export default {
methods: {
greet(text) {
...
0
votes
0
answers
235
views
Vue unit test does not run through the complete function - jest
I am trying to write my first Vue unit test, but I am unable to get the data property to change after function runs
It runs fine on the UI front
I've multiple data objects
data() {
return {
...
3
votes
0
answers
759
views
Is it possible to spy on an imported function within a Vue SFC using Vitest and Vue Test Utils?
I'm working on unit testing all of my components, and I've hit a bit of a snag (or maybe a misunderstanding of how to properly test).
I have a component that receives some parameters from the store, ...
1
vote
1
answer
746
views
How to set grandparent mock data for vue unit test
I am writing unit test for an existing vue component. The component has a method which runs on mount. The method uses return this.$parent.$parent.someData. I am looking for a way to pass grandparent ...
0
votes
1
answer
4k
views
Vue3 Composition API unit tests failing to update modelValue
I'm new to Vue and currently writing unit tests for a search component that I am using in my project. Simply, when the user types in the input field and small X icon appears to the right of the input ...
6
votes
3
answers
2k
views
Reference a computed property in a jest unit test
I'm writing a jest unit test for my Vuejs 2 (Vuetify) component. Setup is pretty simple.
Inside the component I have a prop, which is an object with nested fields:
props: ['testObject']
And I have a ...
0
votes
0
answers
57
views
how to check if a method has been called in a lifecycle hook (JEST + VUE)?
Okey, I have some test method and lifecycle hook
testMethod(){
console.log('test')
}
beforeMount() {
this.testMethod()
},
test
import {createLocalVue, shallowMount} from "@...