919 questions
0
votes
0
answers
27
views
Angular 21 Vitest, FakeTimers and RxJS debounceTime
I could successfully migrate my Angular 20/Jasmine/Karma app to Angula r21/Vitest
All my tests are running correctly, except the ones that use debounceTime from RxJS
As a workaround for now, ny unit ...
0
votes
1
answer
36
views
How to fix ERR_INVALID_URL_SCHEME when initializing C# in WebAssembly in node.js?
While I was able to get my C# code running in the browser as WebAssembly, I get errors like this when trying to run any (vitest) unit tests that load the module that initializes .NET:
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯...
-4
votes
0
answers
52
views
How do I turn off automatic screenshots in Vitest browser/Playwright?
I am using Vitest in browser mode, with Playwright as the provider. Whenever a test fails, a screenshot of the failed test is created in __screenshots__/<filename>/<test-name>. I am unsure ...
0
votes
0
answers
55
views
Type error not caught in vitest.config.ts
When writing a Vitest config file in TypeScript, type errors don't seem to be caught. How to change that (and thus benefit from type checking if an option property is wrong)?
Here's an example vitest....
0
votes
1
answer
109
views
How to avoid target.hasPointerCapture is not a function when testing Radix UI (shadcn) components with Vitest + userEvent?
I'm testing components built with shadcn/ui, which uses Radix UI under the hood.
When running UI interaction tests using Vitest and @testing-library/user-event, I keep getting the following error:
...
0
votes
1
answer
43
views
Mocking Vitest functions for testing Pinia storage
I am struggling adding mocked methods when testing a Pinia store's functionality. There is very little documentation relating to actually testing the stores themselves, as most Pinia's official ...
-1
votes
1
answer
57
views
Accessing calls/args in a global mock with spied functions
In a large Vue 3 app, we have some helper modules that are imported into various components. One of these helpers returns the root node, which itself contains many other methods.
In the app calls to ...
0
votes
1
answer
90
views
Error running vitest with npm run test:ui: Error: listen EACCES: permission denied ::1:51204
I’m trying to run Vitest with the UI enabled using:
"scripts": {
"test:ui": "vitest --ui"
}
When I run it with:
npm run test:ui
I get the following error:
Error: ...
0
votes
2
answers
72
views
$effect “forgets” state change, test crashes with “Cannot read properties of undefined”
I’m trying to write a Vitest unit test for an auto-save feature in a Svelte 5 project.
The test sets meta.settings.autoSaveIntervalMs = 50 so the save cycle finishes quickly, but the $effect still ...
-4
votes
1
answer
66
views
Use property from object as test name in test.for
When I use:
describe("ExtractDateFromText", () => {
test.for(scannedReceiptText)('Filename %s', async (expected) => {
const dateResult = dateFromRawData(...
0
votes
0
answers
19
views
Use MSW with a self-signed certificate for a specific domain
I have a Vite app and configured a domain - say https://abcd.io:5173 - as a domain and certificates are generated for this domain. Now I would like to use MSW for testing. But when I try to enable ...
0
votes
1
answer
91
views
`async` test of a Fastify backend with `@fastify/websocket` times out, but also finishes
I'm trying to test (using Vitest) a part of my Fastify app that uses @fastify/websocket (and transitively ws), but my tests keep timing out despite running to completion. Here's a relevant excerpt ...
62
votes
7
answers
52k
views
Vitest - @ src folder alias not resolved in test files
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 ...
0
votes
0
answers
178
views
Cannot read properties of undefined (reading 'wrapDynamicImport'). Getting this error right after generating a new project and trying to run tests
I ran the following commands in sveltekit to create a new project
npx sv create ch_ui
I selected the following options
┌ Welcome to the Svelte CLI! (v0.8.20)
│
◇ Which template would you like?
│ ...
1
vote
1
answer
51
views
Combine toMatchSnapshot and toBeCloseTo behavior?
In my snapshot, I have objects of the following format:
{
"meanElements": {
"Om": 2.2835713400168607,
"am": 1.3043985097733939,
"em": 0.166565,
...
-1
votes
2
answers
256
views
Vitest : cannot find package 'rollup'
While trying to execute unit tests with Vitest through Yarn in my Angular app I have an error about 'rollup' package :
yarn run test
[INFO] failed to load config from xxx\angular-test\vitest.config.ts
...
10
votes
5
answers
15k
views
Invalid Chai property in Vitest
I have this Vitest test:
import React from 'react';
import { expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { StyledNativeTimePicker } ...
0
votes
0
answers
248
views
Vitest giving TypeError: React.act is not a function with React version 19
I am using React version 19 with Vite and when run Vitest, it's giving error
FAIL src/components/UserPopover/UserPopover.test.tsx > UserPopover > calls only
onCancel when "Cancel&...
-1
votes
1
answer
40
views
Having EBUSY: resource busy or locked, rmdir 'blablabla...\dist' when trying to run Nest project locally via VSCode [closed]
I was facing this exact error every time I tried to run a Nest project locally via VSCode and I didn't find anything related to it on the internet, so I'm gonna post a question and the answer I found ...
0
votes
1
answer
77
views
Can an inappropriate callback be passed to waitFor?
I was going over Road to React (the book by Robin Wieruch), and I encountered a confusing piece of code. The code is on the Testing chapter, page 227:
describe('App', () => {
it('succeeds ...
26
votes
4
answers
33k
views
"describe is not defined" in Vitest
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.tsx ]...
5
votes
0
answers
721
views
Why is Vitest taking too much time to run even a single test file?
My project folder structure is this:
-frontend
-src
-components
-__test__
-pages
-dialogs
- etc
in __test__ folder there are all the test cases for components like ...
5
votes
1
answer
2k
views
Using Storybook and Vitest, mocking a module throws exception
I have a Storybook setup using vitest, and I want to mock a module in a story by way of vitest, so I add the following to the top of my stories-file:
// my-nice-function.stories.tsx
import { vi } from ...
12
votes
5
answers
13k
views
Troubleshooting Vitest setup in vite.config.js with react-ts template
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: { ...
3
votes
1
answer
366
views
How to mock page from $app/state in SvelteKit + Vitest unit tests?
this is my first post — I'm new to both Stack Overflow and SvelteKit. I'm trying to test a Svelte 5 Navbar component that conditionally shows links/buttons based on:
page.data.user — if the user is ...