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.

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
0 votes
0 answers
16 views

how to mock a third party library and assert its functions were called (or spyon) with jest?

I am working with ngrx and signalr, and writing a unit test for my ngrx effect responsible for building, starting and stopping the signalR hub. this is my effect: import {HubConnection, ...
Natalia Cáceres's user avatar
0 votes
0 answers
10 views

jest ReferenceError: Cannot access 'BsNavbarDropdownComponent' before initialization

I'm trying to convert my angular app (NX monorepo) to use standalone components. However when doing so, my Jest unit tests stop working and give the following error: ReferenceError: Cannot access '...
Pieterjan's user avatar
  • 3,586
-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
5 views

React Native + Jest + React Native Testing Library errors

I'm having trouble with a proper config for the following setup: React Native + Jest + React Native Testing Library. Trying to follow the docs and similar issues solutions, nothing works as expected ...
Ania Kowalska's user avatar
0 votes
0 answers
28 views

Adding "test" target config to existing NX libraries

I am working on an application that uses https://nx.dev/ and https://angular.dev/ and is configured with https://jestjs.io/ to run unit tests. I normally use this command to generate new Angular ...
Francesco Borzi's user avatar
0 votes
0 answers
15 views

onClick event not being handled/fired while testing - Custom component with Lit Element using React Wrapper

I have this below component that is a Header Component with an AccessBar and an Icon Component with certain props. All the custom components are actually Lit Element components (uses shadowDOM) from a ...
user26512063's user avatar
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
-2 votes
0 answers
19 views

How can I implement Jest with React useContext? [closed]

I am trying to create a simple snapshot test of a component that implements useContext. I have wrapped the component with the ContextProvider but I am still getting the following error: TypeError: ...
The Bunz's user avatar
0 votes
0 answers
12 views

ReferenceError: Highlight is not defined, we use CSS Custom Highlight API in a fn to highlight query str in texts, how do I unit test it with jest?

I have this highlighting function in a file and I want to unit test it with jest: export function highlightTextFunction(searchingStr: string, rootEl: HTMLElement) { if (!searchingStr || !rootEl) { ...
Koryna Böhm's user avatar
-1 votes
0 answers
10 views

Rollup/Yalc/Babel: "SyntaxError: Cannot use import statement outside a module"

Currently in the process of splitting up a large project into smaller npm packages. for local dev we are using yalc, for the npm package projects we are using Rollup.js with a separate .babelrc config ...
Victor's user avatar
  • 1
0 votes
1 answer
41 views

Angular tests with Jest: How to inject HttpClient: Can't resolve all parameters for xxxx

I'm moving my tests from jasmine/karma to Jest. I'm struggling to inject HttpClient and its testing controller. I'm following https://angular.io/guide/http-test-requests and I get this dummy test: ...
J4N's user avatar
  • 20.3k

15 30 50 per page
1
2 3 4 5
1541