Skip to main content
How are we doing? Please help us improve Stack Overflow. Take our short survey

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.

-1 votes
0 answers
10 views

How to spy on public field with Jest+jest-auto-spies

I've this Angular service that I'm trying to mock: @Injectable({ providedIn: 'root', }) export class NotificationsService { private _notifications = new Subject<Notification>(); public ...
J4N's user avatar
  • 20.3k
0 votes
0 answers
6 views

How can i mock knex transaction

i have unit test for function sync in these code but i get error like below i cant mock the function knex.transaction() for trx. i have tried some another way but i usually get trx is not the fuction ...
NguyenHai's user avatar
0 votes
1 answer
10 views

How to mock recoil custom hook

Custom hook: export const usersState = atom({ key: 'usersState', default: [], }); export const useUsersList = () => { return useRecoilValue(usersState); }; React component: export const ...
Samuel A. Souza's user avatar
0 votes
0 answers
12 views

It is impossible to change the value of a MUI DatePicker or MUI TimePicker with react-testing-library?

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

RollUp/Yalc/Babel/Jest Cannot use Import statement outside of a module

So I am in the process of splitting down large VS projects in to separate modules (built with Rollup, published to an Azure artifacts repository and locally linked via Yalc), and I am running in to an ...
Lewis Moore's user avatar
-1 votes
1 answer
14 views

Getting error in Component testing - Jest & react-native testing library

Getting error when using the render method to test component `Trying to detect host component names triggered the following error: Unexpected token 'export' There seems to be an issue with your ...
Prajwal VK's user avatar
0 votes
0 answers
20 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
24 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
2 answers
21 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
1 vote
1 answer
18 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
  • 459
0 votes
0 answers
16 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
33 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
31 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,595
-1 votes
0 answers
24 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,084
0 votes
0 answers
14 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

15 30 50 per page
1
2 3 4 5
1540