Questions tagged [jestjs]
Jest is a JavaScript unit testing framework made by Facebook based on Jasmine and provides automated mock creation and a jsdom environment. It's often used for testing React components.
jestjs
23,108
questions
-1
votes
0
answers
13
views
How to integrate a Next.js 14 app with MSW? [closed]
Im new to unit testing
i started learning Jest, RTL and found out about MSW
So i've been trying to integrate it to no avail
i feel like i tried everything from the MSW dosc, Yt, google adn this is ...
0
votes
0
answers
10
views
How to handle a component unmounting before a promise resolves in a Jest test?
I'm using Jest to test an information display component. After my onSubmit handler is "clicked", an information card takes the place of the form component.
The onSubmit handler is inside the ...
-1
votes
0
answers
8
views
I'm using Jest to test my API endpoint. I'm new to API testing, I have a error in testing the code
I'm used this code to test my API endpoint using Jest. But, I don't why my code is not running.
const mongoose = require("mongoose");
const request = require("supertest");
const ...
0
votes
0
answers
5
views
Throubleshoting with Authenticated Guard and testing
I'm having troubles with this test and i can't make it wright can someone help me. This suite is not working. Im getting this error:
import { Test, TestingModule } from '@nestjs/testing';
import { ...
0
votes
0
answers
7
views
Mocking NextJS's useParams with Jest and RTL
As titled
I set up the following jest mock for next/navigation
jest.mock('next/navigation', async () => {
const actual = await jest.requireActual('next/navigation');
return {
__esModule: ...
0
votes
1
answer
23
views
How to run Vitest tests parallel in Gitlab with multiple jobs
Our unit tests currently run in a single job on Gitlab. We are using React Vitest (800+ tests) but the job takes way to much time for our liking (7+ min). I saw that you can run multiple jobs in ...
0
votes
0
answers
13
views
Testing state in fetch custom hook
I wrote a custom hook to fetch data that is working fine but I can't test the state exposed by the hook. Specifically, I want to test that:
The loading state is false before fetching (Working)
The ...
0
votes
0
answers
9
views
Jest not able to resolve tsconfig extended from node_modules package
I have a monorepo setup using turborepo, I have picked out my tsconfig and made an npm package out of it that can be extended to multiple apps in my monorepo.
{
"extends": "jc-tsconf/...
-4
votes
0
answers
16
views
Maybe i must to write unit test if im design a API? [closed]
Im a beginner back end developer and im start learn unit test. If im write or design one API in one feature, maybe I must to write a unit test ? please explain
i expect everybody explain me. cause i ...
0
votes
0
answers
36
views
How to test an Angular method with an RxJS subscription that awaits on multiple methods
I'm trying to test an Angular service. Another service provides an observable to which this service needs to react, start some parallel HTTP requests and do something with them.
I'm struggling to test ...
0
votes
0
answers
23
views
How to override the default value of an ENV variable in a JestJS Unit Test while testing an exported component?
I am working on a NextJS+React project and need to write a Unit Test using JestJS that depends on one ENV variable. The variables is named to SITE_BRAND and defaulted to brand value.
This is what the ...
-3
votes
0
answers
44
views
How to setup unit testing for React application using React Testing Library and Jest? [closed]
I have a simple react application that uses RTK Query and React Router. It makes an API call and it has 2 routes
unauthorized
welcome
I need help with testing setup and couple of sample tests using ...
1
vote
0
answers
32
views
getting TypeError: Cannot read properties of undefined (reading 'length') [closed]
I have used MockComponent(FormComponent) inside spec.ts
describe('editing point', () => {
const createComponent = createComponentFactory({
component: PointDialogComponent,
imports: [...
-1
votes
0
answers
26
views
Date.UTC is not a function after spying on Date as a whole
I'm wanting to mock the Date, however after I have spied on the global date object, it seems I can not get the .UTC value...
const mockedDate = new Date("2024/07/29");
jest.spyOn(global, &...
0
votes
0
answers
85
views
Jest tests started failing with TypeError: A dynamic import callback was invoked without --experimental-vm-modules after recent React Native upgrade
I've been trying to resolve this test error for a while now with not success. Recently I upgraded React Native from 0.72.3 to 0.74.3 and got the Android application to build and run, however, I can't ...