Skip to main content

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.

0 votes
0 answers
12 views

mocking createAsyncThunk exhibits odd behavior

I am trying to mock createAsyncThunk from reduxjs/toolkit as follows: // mock.ts file import { createAction } from "@reduxjs/toolkit"; export const mockedToolkit: unknown = { ...jest....
GRZa's user avatar
  • 775
0 votes
0 answers
13 views

jest.config.ts file not working with react-scripts test

I am new to Jest and struggling to setup in my React TypeScript Web app. I want to keep all my Jest configuration details in a single file jest.config.ts. I keep getting an unknown long list of errors:...
aman's user avatar
  • 373
-1 votes
1 answer
14 views

Jest react test : API call failed TypeError: Cannot read properties of undefined (reading 'json')

I am going to test the components below through the jest and react test library. I want to test if the API is called normally when I press the button, So I made the API calling part mock. However, ...
yjyjy131's user avatar
0 votes
0 answers
12 views

How can I mock prompt-sync module using jest

I have this method promptPlayer in the class Player which job is to return to the player the index of an empty slot. But inside the method I am running prompt from the prompt-sync module of JS. Cant ...
Mohamed's user avatar
  • 449
0 votes
0 answers
13 views

Why are my NestJS Guards not included in Jest code coverage?

I have written unit tests for my Nest Guards, and then run just fine and pass, but when I check my code coverage they are not included in that! You can see in my console output the *.guard.ts files ...
Chris Barr's user avatar
0 votes
0 answers
25 views

Nest can't resolve dependencies of the FollowService Please make sure RedisService at index [2] is available in the RootTestModule context. how to fix

FAIL follow/follow.resolver.spec.ts ● FollowResolver › should be defined Nest can't resolve dependencies of the FollowService (aService, bService, ?). Please make sure that the argument RedisService ...
Somyadeep Shrivastava's user avatar
1 vote
1 answer
28 views

Jest error: Jest encountered an unexpected token - query-string import

I'm getting the following: babel.config.json: { "presets": [ ["@babel/preset-env", { "targets": { "esmodules": true } }], ["@babel/preset-react&...
Syden's user avatar
  • 8,585
-1 votes
0 answers
21 views

How to mock my util DynamoDB GetItemCommand implementation?

I've got code that uses GetItemCommand to get data from my DynamoDb instance, however I'm not entirely sure how I go about testing my function that uses it. I don't want to test the GetItemCommand ...
physicsboy's user avatar
  • 6,074
0 votes
0 answers
13 views

How to write test cases for file input using jest?

I am trying to write test cases for input type file but I am getting empty file like this e.g. File {} const PortNumberStep1 = ({ state, phoneTypeData, phoneNumberProviderData, getValues, ...
pratik babar's user avatar
-2 votes
0 answers
17 views

What error is this: "Jest encountered an unexpected token"? It came from "isPortReachable" import of my code to be tested

Im trying to do Jest testing for all my domain/service/business logic of my web app. One of the import was isPortReachable, and Conf, but apparently every file with this import would fail the test ...
Wer Wer's user avatar
0 votes
0 answers
21 views

Need to know jest dom setup in plain vanilla javascript

i created an todo app in vanilla javascript now i needed to test that using jest but the thing jest-environment is not working on that. i need proper procedure to setup get done package.json { "...
praveen gopu's user avatar
0 votes
0 answers
14 views

NestJS & Jest: The presence of jest.config.ts causes "strange behavior" during build

I have a Nestjs service inside my monorepo project with the following structure: / - package.json - packages/ - - frontend/ - - backend/ - - backend/package.json backend is the nestjs service, ...
Northern Bottlenose's user avatar
0 votes
0 answers
17 views

How to change the value of a MUI DatePicker or TimePicker in Jest/react-testing-library?

I have a component that uses the Material UI datepicker and timepicker. function MyComponent() { const [dateFilter, setDateFilter] = useState(moment()); const [timeFilter, setTimeFilter] = ...
CodeMan's user avatar
-1 votes
1 answer
18 views

What is "Argument of type <mock parameters> is not assignable to parameter of type 'never'" in Jest?

I took a bunch of examples online and ChatGPT code to do my testing. I ended up with some red squiggly lines under the parameters mockResolvedValue with the error: Argument of type '{ email: string; }'...
Wer Wer's user avatar
0 votes
0 answers
14 views

Unable to mock JSEncrypt 3rd party library in jest

encryptPassword.js import { JSEncrypt } from 'jsencrypt'; export const encryptPassword = (pwd, rsaPublicKey) => { let retVal = pwd; try { const encrypt = new JSEncrypt(); encrypt....
MLK's user avatar
  • 11

15 30 50 per page
1
2 3 4 5
1540