All Questions
165
questions
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 ...
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 ...
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();
...
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.....
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....
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 { ...
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 ...
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,
...
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 ...
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
│ │ └── ...
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 ...
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 "@...
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, ...
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 ...
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 = [
...