Skip to main content
The 2024 Developer Survey results are live! See the results

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
-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 ...
Patryk Janus's user avatar
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 ...
Zach W.'s user avatar
-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 ...
Kunguma Sakthivel's user avatar
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 { ...
Daniel Hernandez's user avatar
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: ...
Fred A's user avatar
  • 1,712
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 ...
spoilerd do's user avatar
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 ...
brubs's user avatar
  • 1,317
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/...
SOURABH GUPTA's user avatar
-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 ...
Mikhael Scorpion's user avatar
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 ...
J4N's user avatar
  • 20.3k
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 ...
ReynierPM's user avatar
  • 18.4k
-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 ...
noBoom's user avatar
  • 131
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: [...
Kruno's user avatar
  • 169
-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, &...
physicsboy's user avatar
  • 6,074
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 ...
Onyx's user avatar
  • 5,546

15 30 50 per page
1
2 3 4 5
1541