vitest Questions

2

This is the first time when I setup test environment with RTK Query and mock server (msw). Please tell me what I'm doing wrong. Environment Name Version msw 1.2.1 react 18 redux toolkit...
Fugacity asked 18/4, 2023 at 15:41

2

Solved

The question's in the title. With Jest it was console.log = jest.fn(). How do I get and analyse the console output of the code I'm testing?
Brownstone asked 18/4, 2023 at 9:32

1

I'm using vitest in VS Code with the official Vitest test runner plugin. All works as expected, but any console.log() statements don't seem to appear anywhere. Not in the VScode test results tab, o...
Tubbs asked 25/7, 2023 at 9:16

1

'Im migrating from jest to vitest, which has been pretty painless, except I've been using https://github.com/mattphillips/jest-expect-message To help give better messages to students when tests fai...
Meras asked 2/1 at 18:4

5

Solved

I have a vue3 project using Vite/Vitest, as recommanded in Vue.js documentation. Here is the structure of the project: src components // my Vue components here, potentially in sub-folders. For ex...
Prearrange asked 1/6, 2022 at 21:28

1

Adding 'jsdom' to vite.config.ts brings the following error: No overload matches this call. The last overload gave the following error. Argument of type '{ plugins: PluginOption[][]; test: { envi...
Caseation asked 21/9, 2023 at 21:26

0

I made the same settings for running vitest like in this article: https://medium.com/@zamin_mirzad/how-to-setup-vite-js-react-js-typescript-vitest-js-6e01b6436c6a But when I run yarn test I h...
Forestry asked 13/12, 2023 at 17:47

1

I have built a ReactJS application using Vite, and I am testing my application using Vitest. I make heavy usage of react-query within my application. For mocking network requests during testing, I ...
Usually asked 20/3, 2023 at 20:34

1

Solved

I'm porting Jest tests to Vitest. These tests use matchers from jest-extended like expect(val).toBeString(). I tried to put import "jest-extended" in the test file, but the result is the ...
Bondage asked 8/11, 2023 at 13:2

3

I am migrating my project from jest to vitest and I wanna exclude certain files and folders for both test and coverage, I am following the docs but "exclude" does not seem working, whenev...
Scalariform asked 16/10, 2022 at 14:55

2

Solved

How to unit test methods in VUE 3 Composition API (using vitest (preferably) or jest), knowing that methods are not accesible/exportable directly from the <script setup lang="ts">&l...
Nosegay asked 24/9, 2023 at 22:36

1

Trying to migrate some old TypeScript code from CRA to Vite, and getting stuck on a problem with Vitest. The project has dependencies like this: my-project (ESM) depends on: lib1 (CJS) depends on...
Wrasse asked 18/9, 2023 at 10:12

1

My application requires a very extensive loading for certain functions, but vite updates the page by itself causing the loading to restart and lose all the progress already made on the page, I woul...
Freeswimming asked 28/8, 2023 at 13:35

3

I want to mock fs with vitest and I am successfully doing so, however I am using any to do so. Consider import { promises as fs } from 'fs'; vi.mock('fs') it('can mock', async () => { // Prop...
Griselgriselda asked 17/5, 2023 at 15:48

2

I'm using vitest to do some unit tests in my vue application. I've written some tests but they fail with the error message: 'TypeError: default is not a function'. But I do not use a function calle...
Joacima asked 21/7, 2022 at 8:44

1

I’m kinda stuck with testing composition-functions. I’m using vitest with @vue/test-utils, but also found no good way to get it to work with jest. My issue is: How do I test composable functions, w...
Parasynapsis asked 9/9, 2022 at 7:12

2

Is there any way to use different tsconfig file for vitest? I have a large project using vue-cli. Before converting it to vite based I first want to use vitest instead of jest. The problem is that ...
Gam asked 17/7, 2022 at 6:53

0

I am using Vitest for Vue Unit Testing and I am currently faced with this error: FAIL tests/unit/components/MyComponent.spec.js [ tests/unit/components/MyComponent.spec.js ] SyntaxError: At least o...
Transeunt asked 11/8, 2023 at 11:58

2

Solved

I want to test a component using the useNuxtApp composable. This is the component(MyComponent.vue): <template> <div class="flex justify-between"> <span>{{ $fmt(12) }}&...
Weatherford asked 21/7, 2022 at 17:50

2

I am using vite, react and typescript then i got this error, anyone knows how to solve it ? Here is my package.json: { "name": "", "private": true, "version&qu...
Comfortable asked 27/2, 2023 at 4:17

1

I am trying to set up testing for my React app using Vitest, but I am experiencing an error which must be due to some missing dependency or error in my test suite. I'm unsure what exactly is the ca...
Glove asked 29/6, 2022 at 19:30

2

Solved

I want to mock an object method that throws an error but the test is always failing with these errors. I can't post the image yet but please check the link. It shows the test failing. throw new Err...
Goldsmith asked 18/11, 2022 at 9:27

0

I would render my vitest coverage in Azure DevOps UI, I've tried to follow tutorials but it doesn't work: I tried to setup PublishCodeCoverageResults to publish the cobertura xml file as in below:...
Cowshed asked 13/7, 2023 at 9:0

1

Solved

I'm trying to use Svelte to create a simple reactive component. The component loads data from an api server onMount and updates a reactive value (which updates a html element). I have a simple vite...
Arlettearley asked 29/6, 2023 at 2:7

2

I'm learning unit testing in vue with Typescript and I want to test this function: const getCLients =async (): Promise<Client[]> => { const {data} = await clientsApi.get('/clients') retu...
Obstreperous asked 12/1, 2023 at 8:36

© 2022 - 2024 — McMap. All rights reserved.