Skip to main content

Questions tagged [vitest]

Vitest is a blazing-fast unit test framework powered by Vite.

0 votes
0 answers
12 views

vitest problem with the configuration file "Expression Expected" Error in React Component Testing

I'm experiencing an issue when running tests with Vitest in a React project. The test fails with an "Expression expected" error, and adding console logs in the test file does not display any ...
ZEDDOUN Lokmane's user avatar
0 votes
1 answer
44 views

renderHook not rendering items called from API

I have a custom hook (useFetch), which I'm using inside a page to pass data into a <Products/> component. export default function App() { const { products, totalProducts, currentPage, ...
Matheus Oliveira Damião's user avatar
-1 votes
1 answer
41 views

typescript build Vitest node dependency problems

I'm currently migrating a JavaScript project to TypeScript (and this is my first attempt at TS). For some reason, tsc --build throws a bunch of errors for vitest not being able to resolve the node ...
philolegein's user avatar
  • 1,417
0 votes
1 answer
36 views

How test a file drag-and-drop using Vitest?

I'm trying to test a drag-and-drop of a file into a Vue component and right now I'm using Vitest but all the resources on drag-and-drop I found were only for using Jest to achieve that so: How to test ...
Alex's user avatar
  • 5,744
0 votes
0 answers
14 views

Mocking Neo4J GraphQL OGM in typescript / vitetest

I'm struggling to get a clean solution to mock the use of Noe4j GraphQL OGM using vitetest but cant quite work out the best way to do this cleanly.. I do not seem to be able to find a way to mock ...
SB217's user avatar
  • 1
1 vote
1 answer
44 views

Render problem when testing react component

Hello I am trying to make a test for filtering columns, when I filter one column, it will say ´1 kolonner skjult´, if I filter 2 it will say 2 instead. When I make individual tests for these, they ...
perpetter's user avatar
0 votes
1 answer
45 views

How do I expose a library to the global window in Vitest?

So we are in the middle of adding Vitest to an existing project that currently relies on Webpack for bundling our code. We are in the process of rewriting older jQuery code into React. Right now i'm ...
Showcaselfloyd's user avatar
0 votes
0 answers
19 views

Expected "spy" to be called with arguments: [ '/' ]

I want to check if my button takes the user to the home page, but I'm having trouble mocking the useNavigate function from "react-router" This is what I am using to mock the funcion: const ...
Marco Antônio Dal Vesco's user avatar
0 votes
0 answers
28 views

Vitest fails when testing a typescript file

So I have a monorepo with a package called "types". In this package I have installed vitest and I want to test this file: src/marketplaces.ts import { z } from 'zod'; export const ...
Christian's user avatar
  • 996
0 votes
0 answers
19 views

queryAllByRole('checkbox') works different depending on environment

I have a Vitest test that uses expect(screen.queryAllByRole('checkbox').length).toBeGreaterThan(0) Running in the WebStorm test runner, the test passes. Running via nx in the terminal (and in CI) ...
Jonathan Tuzman's user avatar
0 votes
0 answers
42 views

Vitest: TypeError: Cannot read properties of undefined (reading 'once')

I am trying to setup a unittest using vitest based on a reactjs project. This is my unittest code from Gamesettings.test.tsx: import { it, expect, describe } from 'vitest'; import {screen, render} ...
D.U's user avatar
  • 66
0 votes
1 answer
32 views

How do you test a Pinia store state changed by a function within a component?

So I have a very simple test for testing a simple function. Basically I have a "uiStore" with a state "isNotificationsOpen". I have a component that has a function "...
TheYuwana's user avatar
  • 183
0 votes
2 answers
46 views

Issue with typescript compiler not recognising my vitest extended matchers

I have a typescript project where I have some unit tests that use extending matchers from vitest. The test are running fine, but if I run lint I keep getting errors like this one: src/utils/tests/...
paddingtonMike's user avatar
0 votes
0 answers
32 views

Port already in use when testing an Express server with Vitest

I have the following class named Server. This is responsible for container methods to start and stop the server: class Server { private app!: Express; private port!: number; private server!: ...
Ethan's user avatar
  • 739
0 votes
0 answers
13 views

How is a component with multiple setInterval() tested?

There are two setInterval() functions within a component I'm working on. Once the function start_new_game sets the component state variable level equal to '0', the component will invoke useEffect. The ...
0binny0's user avatar
  • 71

15 30 50 per page
1
2 3 4 5
58