Skip to main content

All Questions

Tagged with
0 votes
1 answer
38 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
22 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
1 answer
22 views

Vitest not properly interpreting TypeScript

I have the following setup test: import { describe, it } from "vitest"; import { init, initServer } from "../src"; import dotenv from "dotenv"; dotenv.config(); ...
Ethan's user avatar
  • 739
1 vote
0 answers
29 views

Failed to resolve import "#app/composables/script-stubs (Vitest)

I am receiving the error 'Failed to resolve import "#app/composables/script-stubs"' inside the .nuxt folder in the imports.d.ts file My code is like this and I've tried importing everything.....
Julio S's user avatar
  • 11
0 votes
0 answers
27 views

How to mock single imported variable in vitest for different test cases

I have defined a single constant, who's definition depends on DOM: // utils.ts export const isRootPresent = Boolean(document.querySelector('#root')); My react app uses it do show/hide text: // App....
animatio's user avatar
0 votes
0 answers
39 views

Vitest + @testing-library/react Issue

currently I’m stuck on this one. so i'm implementing a unit test in my turbo repo app with react remix and i'm creating a unit test for this component /apps/my-portal/routes/signin.forgot.jsx import { ...
Cedys Mapa's user avatar
0 votes
0 answers
31 views

Issue typing custom hook parameter on vi.spyOn

I'm using Vite for a React + TypeScript project. I'm currently trying to test some parts of the app using Vitest and I'm facing this problem when I'm tyring to mock data that I receive from a custom ...
Fabricio Lancieri's user avatar
0 votes
0 answers
20 views

Getting an error while executing test case in React Vite

I am using React with Vite. And this is the piece of code for which I am writing test cases - import { otelLogError } from 'instrumentation-logger'; const { data: notificationResponse, error, ...
Nikhil's user avatar
  • 99
0 votes
0 answers
17 views

Use NodeJS CLI flags when running vitest node --enable-experimental-regexp-engine

I have a NodeJS backend, where I would like to use the new alternative RegExp engine in v8. This is enable when I start node like this node --enable-experimental-regexp-engine some-script.js. When ...
florian norbert bepunkt's user avatar
0 votes
1 answer
69 views

Vitest config - Path import error - Does the file exist?

I have a trouble in a repo where I'm using Aurelia and Vitest. The structure is like this: project-root │ ├── src │ ├── services │ │ └── api.js │ │ └── auth.js │ ├── views │ │ └── ...
dbonafin's user avatar
1 vote
0 answers
76 views

Vitest "SyntaxError: Invalid or unexpected token". Fonts files mocking

In my project I switch from jest tests to Vitest, and a problem has arisen: files with fonts and icons are not being mocking when I want to make a snapshot of component. Before that, I processed them ...
Максим Грушецкий's user avatar
0 votes
1 answer
75 views

Tailwind CSS styles are not taking effect during unit testing

Technology Stack: vite react vitest testing-library/react testing-library/jest-dom Test // test/comment.test.jsx import { it, expect } from "vitest"; import { screen, render } from "@...
peterhuan's user avatar
0 votes
1 answer
347 views

In React.js with Vitest, how can I test a list that displays data from an API is rendered properly?

I have a list component to display data fetched from a REST API. I do the fetching in a useEffect hook with no dependency array, and set the result into my state. This is my code: import { useEffect, ...
user178456's user avatar
0 votes
1 answer
103 views

Vue / Vitest : issues in snapshots with dynamic import assets URL

I am migrating my project from Vue-CLI & Jest to Vite & Vitest. Everything worked fine until I tried to make my tests pass through Jenkins. I discovered that some snapshots does not match ...
Audrey's user avatar
  • 1
3 votes
1 answer
709 views

MSW - Error: No known conditions for "./browser" specifier in "msw" package

After doing successful MSW (Mock Service worker) setup for browser. Everything is working fine. Here is my setup files -> //handlers.ts import { http, HttpResponse } from 'msw'; const handlers = [ ...
Ankur Marwaha's user avatar

15 30 50 per page
1
2 3 4 5
11