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
11 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
6 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
17 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
19 views

Jest error: Jest encountered an unexpected token - queryString 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
19 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
14 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
16 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
13 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
14 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
16 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
0 votes
1 answer
26 views

Jest toHaveBeenCalled() doesn't work for me

I am mocking up some function: export const natsWrapper = { client: { publish: jest .fn() .mockImplementation( (subject: string, data: string, callback: () => void) =>...
Nika Chelidze's user avatar
0 votes
0 answers
7 views

Test wp.data with Jest in Block Plugin

I am trying to get my head around testing my Wordpress Block Plugin with Jest. I am specifically struggling how to mock calls to wp.data. See the following function: import apiFetch from '@wordpress/...
Sina's user avatar
  • 170
0 votes
0 answers
22 views

How to test react-native-auth0 library with detox?

I can't find a way anywhere that explains how to properly mock auth0 requests in React Native. Several questions made on detox GitHub says that its not their responsibility to explain how to mock ...
Lavínia Beghini's user avatar

15 30 50 per page
1
2 3 4 5
1540