280 questions with no answers
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
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
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
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?
│ ...
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&...
0
votes
0
answers
56
views
Getting "SyntaxError: Cannot use import statement outside a module" when using Nest, Typeorm, Vitest and SWC
I recently experienced a memory leak in my jest with ts-node tests in my Nestjs project. After debugging, all evidence pointed towards jest being the issue so I started to migrate to vitest, following ...
0
votes
0
answers
34
views
Test Contentful composable with useNuxtApp - function undefined
I have a Nuxt composable that fetches data from Contentful using the contentful client's getEntries function. It's working on the frontend of my website but when I run my tests i'm getting:
TypeError: ...
0
votes
0
answers
541
views
How to setup Vitest with React Native / Expo? Getting: RollupError: Parse failure: Expected 'from', got 'typeof'
I can run my Vitest usually, but when I try to import a react native link, it breaks with the error below:
RollupError: Parse failure: Expected 'from', got 'typeof'
At file: /mobile-app/node_modules/...
4
votes
0
answers
266
views
How to test useSuspenseQuery hook
Recently I read about new hook useSuspenseQuery provided in @tanstack/react-query v5.
Previously I have used useQuery and have written unit tests on it.
I am trying to write unit tests on ...
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 ...
0
votes
0
answers
87
views
Vitest: TypeError: Unknown file extension ".woff" in package from React TS project with vitest
I am trying to set up unit tests for a frontend project. Currently, i am trying to use vitest, since we use vite as well. Additionally i am going with HappyDom and TestingLibrary. Now, i am facing a ...
0
votes
0
answers
70
views
Select Doesn't Filter Correctly in Tests
My original app is based on the VS template ASP.NET React.ts (It has Vite).
I am testing a frontend part in VSCode using Vitest (it is my first time using Vitest), but it seems I cannot correctly ...
1
vote
0
answers
102
views
Not all components impacted by coverage
for a Nuxt.JS project I have this coverage:
As you can see, only a few of my components are tested (green), while the rest are not impacted by any tests I run. Even components like ColorPalette or ...
0
votes
0
answers
168
views
Vitest + Playwrigth + LitElement, browser not working
TL;DR
I want to run my unit tests using Vitest but when using the fixture from @open-wc, it doesn't.
The problem
I have a project using Lit Element with a lot of unit tests and I'm using Playwright as ...
0
votes
0
answers
130
views
vue 3 pinia testing - spying and asserting on actions
I have the following simplified pinia store:
export const useMyStore = defineStore('myStore', () => {
const doSomething = (param) => {
console.log('doSomething called with: ', param)
...
0
votes
0
answers
35
views
Component unit testing in a nuxt module
First of all I have to say that the nuxt documentation for unit testing a nuxt module is sooo bad, me and all my colleagues are not able to create even a tiny unit test. So what I am trying to do is ...
0
votes
0
answers
179
views
Vitest: Module mocking in browser mode
Is there a special configuration I need for vi.mock('../src/some/file', ...) to work in browser mode?
Is it supported for a specific provider or browser?
I think it's implemented, but I can't get it ...
1
vote
0
answers
291
views
How to mock Nuxt 3 composables(useAsyncData & useRuntimeConfig) in unit tests
The page that I'm trying to write unit tests about is as follows:
<script setup lang="ts">
import { Content, fetchOneEntry, isPreviewing } from '@builder.io/sdk-vue'
import { useRoute }...
0
votes
0
answers
171
views
Mocking a service/object without having to recreate the whole dependency tree
I'm building a browser library for consumption by our clients where they can include it in their site and utilize it to access our services, etc.
I am trying to set up unit testing for the library. ...
0
votes
0
answers
47
views
Mock react module to test error boundary for web-component
I am writing a React component that wraps an external web-component. Since this is external I want to wrap it in an error boundary.
Everything works in production, but I encounter some problems when ...
1
vote
0
answers
86
views
How to simulate the behavior of closing v-dialog in Vitest?
I try the fireEvent to click outside or emitted 'update:modelValue' but the v-dailog element still visible. So how can I correctly simulate the closing behavior of v-dialog ? Thanks in advance for ...
0
votes
0
answers
71
views
Mock working in test file but not in tested file
I'm trying to migrate a project from Jest to Vitest and I'm having issues with mocks. I can't figure out why, when mocking a third party module and using mock implementations/mock returned values, ...
0
votes
0
answers
19
views
ApolloError: No more mocked responses for the query: mutation
I am getting an error "ApolloError: No more mocked responses for the query: mutation CreatePost($text: String!, $title: String!, $imageUrl: URL, $videoUrl: URL, $organizationId: ID!, $file: ...
0
votes
0
answers
47
views
Cannot mock hashSync function
I have a problem with Vitest (in TS). Namely the mocking of hash functions is not working properly. I have two methods that handle hashing and compare:
hash.ts:
import * as bcrypt from 'bcrypt';
...
0
votes
0
answers
247
views
An error occurs when writing tests for node:crypto with Vitest
I want to write tests for the following function using Vitest.
import { randomUUID } from "node:crypto";
export const getRandomUUID = (): string => {
return randomUUID();
}
I wrote ...