vitest Questions
7
I am new to testing and I was trying to use vitest for testing my mern social media app. looking for references to test a react component using vitest i found this article https://eternaldev.com/bl...
Forklift asked 7/8, 2023 at 18:6
3
Solved
installed pnpm add -D vitest and pnpm add -D @vitest/ui in my project dir, when i try vitest --ui, I get this error
vitest : The term 'vitest' is not recognized as the name of a cmdlet, function, s...
3
I'm working on a Nuxt.js project and using Vitest for unit testing. I need to verify if the navigateTo function from Nuxt.js is called with a specific path in my tests.
Here's the relevant part of ...
3
I have the following tsconfig configuration:
{
"include": ["tests/**/*.ts"],
"exclude": [],
"compilerOptions": {
"composite": true,
"lib&...
Thruway asked 17/8, 2022 at 16:56
9
I am trying to migrate my tests from jest to vitest. I have a test suite that uses the dotenv package to pull in my .env variables.
I have this in my test suite
beforeAll(async () => {
vi.clear...
1
I have the following files in a React app with Vitest (which has the same API as Jest):
// hooks/useEntities/useEntities.ts
return useEntities() {
// this hooks send api requests so I will mock i...
Cesar asked 15/12, 2022 at 15:46
4
I'm trying to test a component in React that uses RTK Query + MSW + Vitest. It works fine on the browser but while testing RTK Query with vitest it throws this error:
{ status: 'FETCH_ERROR', error...
3
I'm trying to setup vitest + @vue/test-utils but I can't test some components that use ref(Vue) or useCookie (Nuxt), I have the same problem with Pinia as well where I import globally 2 functions i...
2
Solved
I have a simple composable useRoles which I need to test
import { computed } from "vue";
import { useStore } from "./store";
export default function useRoles() {
const store =...
Halflight asked 6/9, 2022 at 10:54
6
I am trying to get vitest globals api to work so I can write describe, test and expect functions without importing them in each test file like in jest.
I have managed to get tests passing by follow...
Essieessinger asked 8/3, 2023 at 22:27
5
Solved
This is the error I got. There is a problem with the file path I defined in the "vite.config.ts" file. Can you help me?
Error Log
Error Message:
FAIL tests/utils/ConvertFromDomainToCountr...
Neurovascular asked 21/3, 2023 at 7:47
4
I'm trying to understand the logic of mocking the Vue-Router with Vitest.
For this, I tried to set up and mock my test environment on a very simple project. When I tried to proceed according to the...
Idioblast asked 26/10, 2022 at 13:56
1
I'm in a Vite/React/TypeScript application and I'm configuring my first test with Vitest.
When I run my Button test (yarn vitest), I get this error:
packages/frontend/src/components/Generic/Button/...
Cushman asked 17/2, 2023 at 9:26
3
Solved
I'm starting out with Vite for a React application but unable to get jest tests working. I am trying to use Vitest with experimental ES module.
I am getting:
FAIL src/App.test.tsx [ src/App.test.ts...
Alidaalidade asked 9/4, 2023 at 14:11
1
I am currently using Vite with Vitest to perform unit testing for my React components. However, I am encountering an issue where the Tailwind CSS classes applied to my components are not being reco...
Conners asked 17/7, 2023 at 15:12
1
Solved
I'm basically trying to mock an external module in the same way for all my vitest tests, and it's surprisingly not trivial. In Jest, I would just create a __mocks__ folder at the root, and it appea...
Buzzell asked 10/5, 2023 at 0:18
4
I am testing pinia store in nuxt3 app.
Inside setup() of store I'm using useRuntimeConfig to get initial value for counter from public config variables and I got this error ReferenceError: useRunti...
13
Solved
Trying to setup vitest on an already existing vite (vue 3, typescript) project.
My vite.config.ts looks like this:
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
export...
Apteral asked 6/5, 2022 at 19:12
3
I have this Vitest test:
import React from 'react';
import { expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { StyledNativeTimePicker } from
'....
Hyperemia asked 6/12, 2023 at 9:44
1
I am running vitest runner. Then I see that someone probably vitest is generating from my .ts files some .js files:
The error message I get seems to be originating from the uiElementsCreator.test....
Entropy asked 21/2 at 16:44
1
I have a class A that imports class B from a different module and instantiates it. In my test for class A I'd like to stub/mock some of the methods of class B.
Some example code:
// Formatter.ts
ex...
Attribution asked 30/3, 2023 at 17:33
3
I would like to set (actually mock) a timezone in my Vitest tests to get deterministic results in all time zones they will run in.
I run my tests on a local machine and also in CI/CD environments t...
1
Solved
I'd like to do some integration testing of my svelte + page.js-based router using vitest, but I'm running into an issue where the jsdom instance only updates correctly once per test file.
In the fo...
Expiate asked 27/11, 2022 at 11:33
5
Solved
I have been killing myself trying to figure out how to test a Vue component with a v-dialog, something which worked perfectly fine in Vue2. Currently I am using Vue3, Vitest, Vuetify3.
here is a ve...
Bennion asked 1/1, 2023 at 18:41
2
Solved
In VSCode, I have a very small project with vite and vitest installed. With vitest, unlike with jasmine or jest, you need to explicitly import symbols like describe, it, expect etc.
Unfortunately, ...
Scowl asked 19/3, 2023 at 10:23
1 Next >
© 2022 - 2024 — McMap. All rights reserved.