919 questions
0 votes
0 answers
42 views
Initializing service values before tests using Angular 21 and Vitest
I've just moved over to Angular 21 and started using Vitest. I'd like to initialize one of my services before the tests starts. So I added provideAppInitializer in src/test-providers.ts like so: // ...
0 votes
0 answers
62 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 ...
Advice
1 vote
1 replies
192 views
Angular: Vitest vs Jasmine/Karma
I am a bit confused with the Angular testing landscape. I have seen that Vitest will become the new default, replacing Karma. The question I then have is what about Jasmine. Does Vitest replace only ...
0 votes
1 answer
48 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: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯...
-1 votes
1 answer
92 views
Alias import issues in Vitest
I'm trying to have Vitest + Storybook setup and the following is my vitest.config.ts: import path from "path"; import { fileURLToPath } from "node:url"; import { defineConfig } ...
-4 votes
0 answers
63 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
1 answer
72 views
Vitest config for Laravel and Vue
I have a Laravel 12 project built with the Vue starter kit. By default, the project didn't have any frontend testing libraries. I want to add tests in Vitest. When I run vitest, I get the error: Error:...
0 votes
0 answers
60 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....
1 vote
0 answers
46 views
How do I specify to WebStorm the canonical definition of the Vuex store?
Problem I have a Vue project that uses Vuex for state management. Parts of the Vuex store are often mocked in unit tests (Vitest). When Vuex stores are defined in both the main production code and in ...
0 votes
2 answers
97 views
How to remove setTimeout in Vitest?
I have a function that allows users to register. After successful registration, the user is redirected to the home page (after 5 seconds). Before being redirected, the user receives a toast ...
0 votes
1 answer
124 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
52 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
69 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
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
0 answers
36 views
Vitest/JSDOM: Native <dialog> Not Opening in Tests Despite All Fixes (Lightbox Modal Component)
I'm working on my portfolio site, and learning how to write TypeScript and test scripts. I'm stuck resolving these errors: RUN v3.2.4 /Users/sigma/Documents/Websites/Site/Site 5 ❯ tests/lightbox....