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

All Questions

Tagged with
0 votes
0 answers
12 views

Mock static method of object in react jest

I want to mock a static method defined outside a component. Here is my component: import Authenticate from '/api/Authenticate'; export default class MyComponent extends React.Component { render() { ...
Sonam's user avatar
  • 1
0 votes
0 answers
5 views

Jest - react-native-color-matrix-image-filters/dist/CMIFColorMatrixImageFilterNativeComponent.js: Could not find component config for native component

I have a React Native Android project and I just upgraded the react-native version from 0.72.3 to 0.74.3. After a fair amount of library upgrading, TS and Lint fixes, etc I was able to get my ...
Onyx's user avatar
  • 5,546
-1 votes
0 answers
13 views

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax,

This is the error i am getting: Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such ...
user26524488's user avatar
-3 votes
0 answers
37 views

JS - required lib returns a constructor - how to test? [closed]

There is this NPM lib: https://www.npmjs.com/package/clamscan It is being used like this according to the docs: const NodeClam = require('clamscan'); const ClamScan = new NodeClam().init(options); ...
Phil's user avatar
  • 7,432
0 votes
0 answers
19 views

Angular component testing with Jest, Spectator and asynchronus operations

I was trying to figure it out by myself for last two days but I have no clue what I'm doing wrong. It has to be related somehow to asynchronus operations (probably selectors from ngrx) in my component,...
D.Zet's user avatar
  • 769
-1 votes
0 answers
10 views

Jest- not getting coverage for Object.key line

I have a function that takes in an object, manipulates it, checks that the manipulated object still contains data, then iterates through the object's keys using Object.keys / forEach and passes the ...
Patrick Lines-Mattei's user avatar
0 votes
0 answers
15 views

Create a file/folder during a test with Jest always fails

I have a file watcher that triggers a callback every time a file in a specific path is update. I want to write a test to make sure this happens, so my approach is the following: create a temporary ...
ste's user avatar
  • 3,187
0 votes
0 answers
11 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
-1 votes
2 answers
24 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
20 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
  • 469
0 votes
0 answers
24 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
1 answer
31 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
1 answer
52 views

Jest Unit test for nested function javascript

How do I write a unit test for nested functions? I tried to reach the reject value with the test below but the test is failing. The output of the failed message does say there is an error and the test ...
jSvSL's user avatar
  • 39
-1 votes
0 answers
18 views

Using the Spy in Jest on a ProductLookupClient in the test class always returns undefined

I created a service which returns a list of products given the productId, However, when I mock the value to be returned by the ProductLookupClient it always returns undefined in my test class using ...
BreenDeen's user avatar
  • 630
2 votes
0 answers
60 views

Is there a way to verify order of HTTP calls?

I am using the Nock library for mocking HTTP calls, with Jest as the testing framework. I am loading mock calls from a json file. Tests work fine, but I want to make sure certain calls happen before ...
Amir Rachum's user avatar
  • 78.7k

15 30 50 per page
1
2 3 4 5
546