831 questions
5
votes
1
answer
2k
views
how to test a 'redirect' in Nuxt's middleware?
I have a nuxt page that redirects user if a condition fails in middleware, I'd like to test that a redirections occurs.
middleware({ $featureFlag, store, route, redirect }) {
if (!$featureFlag....
1
vote
1
answer
3k
views
Cannot access emit property while testing click event on Vue 3
I'm new to testing and I'm trying to test a component with Vue test-utils, but I'm having trouble when I try to test a click on a imported component.
This is my test file:
import { Table, Input } ...
1
vote
0
answers
719
views
vuejs with vite jest and vue-util-testing getting SyntaxError: Cannot use import statement outside a module
Using the base project https://github.com/antfu/vitesse-webext I need to add the unit test capability, but getting error: SyntaxError: Cannot use import statement outside a module.
I extended the ...
2
votes
2
answers
4k
views
How to import/include plugin in testing with Jest / Vue-test-utils?
When testing a base button implementation using Jest and Vue-test-utils, the tests work but I am getting the following warning:
[Vue warn]: Unknown custom element: b-button - did you register the ...
0
votes
1
answer
169
views
How to cover ajax calls in jest code coverage
I have following method in vue file in which api call is there as below
getZipcode(city){
ajax.get(`${CONSTANTS.STANDARDAPIURL}Geographic/ZipCode?cityName=${city}`, {}, (res) => {
...
1
vote
1
answer
1k
views
How to cover beforeDestroy hook in jest code coverage
I have following beforeDestroy hook in Employee.vue file
beforeDestroy() {
this.checkIncompleteValues()
}
and in test file unit test written as
test('beforeDestroy method', () => {
const ...
0
votes
0
answers
618
views
Vuejs testing library - how to write a test to handle axios request in "mounted" hook
I have a vue component that fetches data from an api in the "created" function. I'm just getting up and running using the following testing stack:
"devDependencies": {
"@...
1
vote
1
answer
1k
views
Vue test utils: how to setProps if they are used in mounted()
I'm using jest / vue-test-utils to test a component, and I can't find a way to set props if they are used in mounted().
The component has one prop queryFilter: { type: Object } which is used within ...
2
votes
1
answer
2k
views
How to test with jest and vue-test-utils simulate upload file
I'm use jest with vue-test-utils and I want test method for upload files. This method in vue file component.
async uploadFiles(file){
this.$refs.iconUpload.setAttribute('data-load', 'loading')
let ...
0
votes
1
answer
1k
views
Vuex Store keeps state somehow between tests
I have a strange problem with testing the frontend part of my project. I use Vue components for the frontend. The project is website for teachers to set appointments for the assistent(s) so the ...
1
vote
1
answer
4k
views
Why is wrapper.findComponent not working for @vue/test-utils
When I try using wrapper.findComponent, I get the following error:
ErrorWrapper { selector: { ref: 'loginTab' } }
I have searched online but to no avail. Here is my test code:
describe('Sign-Up Test ...
3
votes
1
answer
909
views
How to check if mixin was passed to the component?
I am testing a VueJS 2 application using vue-test-utils library and I want to check if the mixin was passed to specific component, something like mounting the component using mount and accessing the ...
-1
votes
1
answer
580
views
How to unit test code inside validate method nuxtjs vuejs jest
I have code inside validate method if condition true it returns true else false.
I want to test that code. Is there any way to do it.
1
vote
1
answer
1k
views
Could not locate module ~/assets/images/flags/undefined.png mapped as
I have some img tag which I fill it with dynamic address with require, it works as expected in the component but when I write a test for it throws this error
console.error
Error: Configuration ...
1
vote
1
answer
318
views
How can I DRY up the code by mounting Vue component in the beforeEach hook using typescript?
Here is my code. I want to DRY up this case.
describe("Stored id", () => {
it("ID empty", () => {
// when
const wrapper = mount(SigninPage, options);
const vm ...
1
vote
1
answer
4k
views
[Vue warn]: Error in v-on handler (Promise/async): "TypeError: Cannot read property 'get' of undefined" vue test util
I'm trying to mock an axios put request in nuxt.js like this:
The component method(Composition API approach):
const doSomething = async (): Promise<void> => {
const token = $cookies.get(&...
1
vote
1
answer
1k
views
How can i write test for my component which is use Vuex with Typescript and Composition Api in Nuxt2 and Vue test util(VTU)?
I have trouble with finding a good resource for writing tests for my component which is using Vuex with Typescript and Composition Api in Nuxt2, and how can I do this?
Here is my component codes:
<...
1
vote
1
answer
501
views
Trouble getting wrapper for dynamic child component
I'm trying to write a unit test for a VueJS 2 component that has a dynamic component that changes as the state changes.
<template>
<div>
<component ref="dynamicComponent" ...
1
vote
0
answers
247
views
VueJs 3 TDD a component which depend on external library component
I'm trying to develop a VueJs 3 component (and composition API) with TDD approach.
The UI : It's a Pop Up that contain a file uploader. The user have to select a file, then a validation button should ...
0
votes
1
answer
452
views
mock store getters inside Global Guard does not work
I created a global guard that uses getters from store.
I am trying to mock some getters from store for testing purpose. The problem is that mocking
does not work.
// router/index.ts
export function ...
0
votes
1
answer
760
views
vue test utils mount option data not working with compostion api
When i am learning the vue-test-utils from the offical site conditional-rendering.
I tried to change the option api to composition api.
It seems like the mount option data not working with the ...
1
vote
1
answer
1k
views
How to test the value and display of a v-text-field?
I'm having an issue trying to test what the contents of a v-text-field object is and it's driving me crazy. I'm having a bit of trouble following the documentation, so any help is appreciated.
I have ...
0
votes
1
answer
813
views
Vue Test Utils with Jest - Mixins not working
I have created a local Vue app and I need to mix a method into all components. The problem is whenever I mount the app the method does not appear to be mixed for child components. Here is my code:
...
2
votes
0
answers
1k
views
How to run Vuejs tests with without JsDom?
I have a Vuejs project with Jest and Vue test utils.
Currently I'm running my unit tests in JsDom test environment.
I want to change my test environment to "node", because it's a lot faster ...
0
votes
0
answers
579
views
jest chai vuejs trigger('click') not working
i try to create a simple test who :
click on button
show if dropdown is open
i try to simulate a click with trigger but it is not working,
do you have any idea what i am doing wrong?
describe('...