Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
18 views

Mock being ignored, jest node

I'm trying mock a database with this test but the mock seems to be ignored. I can't think of a reason this could be? import { jest } from '@jest/globals'; jest.mock('../database', () => ({ ...
Ed Lynch's user avatar
  • 615
-1 votes
0 answers
32 views

Can't add custom matcher to expect because of TypeError

I'm having problems adding a custom matcher to Jest. This example from the Jest docs doesn't work in VS Code: import {expect} from '@jest/globals'; import type {MatcherFunction} from 'expect'; const ...
starkipraggy's user avatar
0 votes
0 answers
91 views

Jest encountered an unexpected token, In React app

I'm trying to run the test case for the app. But its showing below error. Can someone help me to clear the issue. Attaching the code repo. https://github.com/Arun12Muralidharan/team_tracker I can't ...
Arun Muralidharan's user avatar
0 votes
0 answers
17 views

Can not test shadcn input otp component with Jest

I'm creating an OTP page using Shadcn Input-OTP. Before importing input-otp component. All tests are running fine. But when it tries to run this component. it gives: ReferenceError: ResizeObserver is ...
Re9iNee's user avatar
  • 558
0 votes
1 answer
40 views

Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components)

This issue occurs when Jest fails to load SVG files. The error details are as follows: Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for ...
Blue A's user avatar
  • 333
0 votes
0 answers
43 views

I'm getting an error when running tests with jest and remix

I'm getting an error when running tests with jest and remix I'm trying to set up a project using remix and I took the test I saw in the doc as an example to test in the project and I'm getting an ...
carvalhothiago's user avatar
0 votes
0 answers
70 views

.env variables are not being loaded/read correctly

Our project is a React and TypeScript project made with React App Rewired first, but migrated to Vite now. I have been working on getting Jest to work (after trying to use Vitest, where I ran into ...
exodunes's user avatar
0 votes
0 answers
38 views

NestJS not injecting mocked module unless provider tokens are used

I'm writing unit tests for a sandbox project to test a few things in NestJS. I've run into an issue where a class that takes an injected service (authService) is showing up as undefined when being ...
Jas Singh's user avatar
0 votes
0 answers
18 views

How to mock AsyncIterable paging sub-call from Jest mock?

I'm trying to mock an Azure SDK PagedAsyncIterableIterator, using Jest. The unit test fails on the ".byPage()" method call, with the error TypeError: this.storageManagementClient....
S.S.'s user avatar
  • 738
0 votes
0 answers
69 views

Jest with TypeScript - Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'

I'm trying to use Jest in my Express API with TypeScript. However, every time I try to execute npm run test, Jest complains about the ESM. I've tried many configurations, but none of then solved the ...
Marcus Novaes's user avatar
1 vote
1 answer
48 views

TypeError: configSet.processWithEsbuild is not a function when running Jest tests with Angular

I am trying to run my Jest tests for an Angular project, but I'm encountering the following error: FAIL src/app/app.component.spec.ts ● Test suite failed to run TypeError: configSet....
Baisakhi Panda's user avatar
-1 votes
0 answers
38 views

Jest Mock Error :- Here test cases are not working fine

So here I have written test cases in jest for my project. When I run all the test cases together some test case fails where same mocks are being shared but when i run together it works fine. This is ...
Aditya Thakkar's user avatar
-1 votes
1 answer
39 views

Trying to mock all the functions of a JavaScript class with Jest

I am trying to mock a JavaScript service class (AppInsightsService) that I pass in to a tool class (OrderHistoryTool) to use. I don't want to return any data from the mock - I just want to ignore all ...
Westy's user avatar
  • 301
1 vote
0 answers
33 views

Cannot find module '@angular/core/testing' from 'node_modules/jest-preset-angular/build/config/setup-jest.js'

Upgrading from angular 12 to angular 16. In the process 100% of my tests seem to be failing. All the errors seem to signify a missing node module. I am not sure what I am missing. Any help is ...
Emmanuel Huff's user avatar
0 votes
0 answers
40 views

How to use path aliases in Jest tests when a test directory is alongside the source directory

I have a project where my Jest ./test directory is at the same level as the ./src/ directory. I've added path aliases to my TypeScript project, but my Jest tests' path alias imports are throwing the ...
Torc's user avatar
  • 1,274
0 votes
0 answers
16 views

Jest not able to resolve tsconfig extended from node_modules package

I have a monorepo setup using turborepo, I have picked out my tsconfig and made an npm package out of it that can be extended to multiple apps in my monorepo. { "extends": "jc-tsconf/...
SOURABH GUPTA's user avatar
3 votes
0 answers
495 views

Jest tests started failing with TypeError: A dynamic import callback was invoked without --experimental-vm-modules after recent React Native upgrade

I've been trying to resolve this test error for a while now with not success. Recently I upgraded React Native from 0.72.3 to 0.74.3 and got the Android application to build and run, however, I can't ...
Onyx's user avatar
  • 5,576
0 votes
0 answers
23 views

Error with pg in Jest-ts testing : Jest has detected the following 1 open handle potentially keeping Jest from exiting: ● TCPWRAP

I have been facing the problem where my Jest test is not ending gracefully. (I prefer not to use --force-exit). this is my jest code. FYI the tests passes. This is an integration testing. import ...
IamDealer's user avatar
0 votes
0 answers
65 views

Jest errors: Need to call TestBed.initTestEnvironment() first AND zone-testing.js is needed for the fakeAsync() test helper but could not be found

This is an example of a test: import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FooterComponent } from './footer.component'; describe('FooterComponent', () => { let ...
Aria's user avatar
  • 383
1 vote
1 answer
21 views

TypeScript JSX Syntax Error in Jest Mock for react-native-modal: Operator ‘>’ cannot be applied to types ‘View’ and ‘{ children: React.ReactNode; }’

I’m trying to create a Jest mock for react-native-modal in a React Native project using TypeScript. However, TypeScript doesn’t recognize the return statement as valid JSX. It throws the following ...
Mike S.'s user avatar
  • 2,728
0 votes
0 answers
12 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
32 views

Error: Testing Mantine v6 Components with Jest in an Existing CRA App

I'm facing challenges while trying to add tests using Jest to my existing Create React App (CRA) project, which uses Mantine v6 components. I've been following the testing guidelines in the Mantine ...
Soham Kasar's user avatar
0 votes
0 answers
17 views

@module-federation/typescript - Federated Types - Conflict with Jest

I'm trying to typing my modules using @module-federation/typescript So far, is all good, follow the steps I was able to do it. The problem right now is that when I running my tests I'm having this ...
jvrdom's user avatar
  • 368
-1 votes
1 answer
39 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
39 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
0 votes
1 answer
26 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
  • 33.2k
0 votes
0 answers
19 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
1 answer
49 views

Code coverage not working as expected on Linux and Mac

I have a Next.js project which uses React, MUI and TypeScript and Jest (with RTL) for testing. I have achieved 100% test coverage on Windows, but when I run the test coverage on a Mac or my Ubuntu CI ...
VelizarStavrev's user avatar
0 votes
0 answers
72 views

ts-jest unable to process a file

I am new to jest and am trying to implement unit tests in a sharepoint framework solution. I am using ts-jest to process my typescript files and am currently struggling to get a self built package to ...
Ludie's user avatar
  • 1
0 votes
0 answers
21 views

Jest has different behavior in watch mode

I'm writing a extension for chrome omnibox. And I'm using jest to write testing, but I found that the behavior of npx jest and npx jest --watchAll are different. Detailly, npx jest works fine and it ...
July Treee's user avatar
0 votes
1 answer
54 views

Nest can't resolve dependencies of the I18nService

getting error when i try to run test cases import { Test } from '@nestjs/testing'; import { appConfig } from '../app.config'; import { CommonBotModule } from '../common/common-bot.module'; import { ...
Nishad Mahajan's user avatar
0 votes
0 answers
21 views

Unit test with NestJS, Jest and GraphQL : import module fail

I'm new to TDD and Jest, and trying to test the CRUD routes for my app created with NestJS. The tricky part is that I use GraphQL and could not find any help online that works, at least for me. I have ...
SgO's user avatar
  • 27
0 votes
1 answer
37 views

Nestjs jest unit test returns this.userModel is not a constructor

I am down to one failed unit test and for the past 3 days I have not been able to pass it. I am getting the followning error in the console related to the jest test: FAIL src/user/user.service.spec....
Erik James Robles's user avatar
1 vote
2 answers
431 views

Ts-jest SyntaxError: Cannot use import statement outside a module

Issue I'm running into error SyntaxError: Cannot use import statement outside a module for my jest unit tests after switching one of the packages in our dependencies. The package is a hard requirement ...
Shi Cheng's user avatar
  • 129
0 votes
0 answers
22 views

(Jest/ ts-jest) Mocking exported function is not working

I'm trying to mock a simple exported function in a test with Jest. The problem is that the mocked function is not being called. example.ts export const exampleFn = () => { return 'example' } ...
sheva's user avatar
  • 11
0 votes
1 answer
92 views

Mocking fetch return response using Jest in Typescript

I have a function that calls fetch() and handles different cases of its response data. When trying to mock the global fetch function using Jest I am having trouble with the Response type. I only need ...
justaprogrammer2's user avatar
1 vote
1 answer
30 views

Jest. The original function is called instead of the mock function

I'm facing an issue with function mocking in Jest, especially when one function calls another within itself. I'm using Jest to test the tools module where testBar calls testBar1. I'm trying to mock ...
iglushkov's user avatar
0 votes
0 answers
15 views

Why is Jest plain javascript unit test trying to read NextJS?

I added Jest to make some unit tests of plain javascript classes. They were working, but I added some more code and now I tried to execute the tests and got this: ● Test suite failed to run ...
JorgeeFG's user avatar
  • 5,883
0 votes
0 answers
66 views

Jest running failed: Unexpected token 'export'

I'm trying to run my tests using jest and I keep facing this error Details: /Users/mamad/repos/New Mindro-ai/mindro-dev/web-client/node_modules/react-markdown/index.js:9 export {Markdown ...
Mohamad Askari's user avatar
0 votes
1 answer
72 views

Jest in a TypeScript monorepo

I'm working on a TypeScript monorepo and I'm trying to run Jest without the need to run yarn build in order to run yarn test. If I run the application through tsx it runs perfectly (finding all the ...
Daniele Ricci's user avatar
0 votes
0 answers
20 views

How to test ,using jest, an express app built with ts if I have a specific ts compiler config?

any idea how to test express app with this ts config? I tried jest, but I get errors because of wrong extension, that's .js However, you have to use .js inside of ts files since module is set to ...
Betto Raite's user avatar
0 votes
1 answer
83 views

Jest Configuration Error: Cannot Use Import Statement Outside a Module in React and TypeScript Project

I'm encountering issues when running Jest in my React and TypeScript project. The errors I'm facing are related to ES module imports. Here are the errors i get: C:\projects\my-project\web\node_modules\...
Milad Zai's user avatar
0 votes
0 answers
48 views

Nx react testing with jest

Im trying to test an app project inside a nx repo that references components in a lib project. But it seems like it fails when loading the external lib, what am i missing. I can run the test just fine ...
Jacob Hansen's user avatar
0 votes
0 answers
74 views

How can I Test 'react-slick' library with Jest?

I have been trying to achieve 100% coverage in my Slider component, but I need to test the branches of these functions: const nextSlide = () => { if (sliderRef.current) sliderRef.current?....
Saisho's user avatar
  • 1
1 vote
0 answers
35 views

TypeError: Cannot read property 'explorerPage' of undefined

I am upgrading jest from version 23 to 29. My project used to work fine before the upgrade, suddenly started observing this issue. I use Typescript as a language. TestPageDefs Module looks like below: ...
Manoj Kumar's user avatar
0 votes
0 answers
57 views

Visual Studio Code debugger stoped working after migration to esm-only package ussage

Issue My visual studio code debugger stoped working as soon as we moved our code use latest esm-only packages. After we made the changes in .swcrc and typescript config the debugger throws the error ...
alap's user avatar
  • 647
0 votes
0 answers
11 views

How to make ts-jest supports static initialization blocks syntax?

Test suite failed while the code includes static initialization blocks. class Model { static { this.schema.index( {} ); } } ● Test suite failed to run TypeError: Cannot read ...
LCB's user avatar
  • 1,050
0 votes
1 answer
84 views

ts-jest nestjs Cannot read properties of undefined of an enum

I'm creating an application using NestJS and using ts-jest for e2e testing. This is my code repository: https://github.com/redplane/jest-issue I have one controller with the following logic: @...
Redplane's user avatar
  • 3,121
-1 votes
1 answer
37 views

Unable to get coverage for callback functions passed from argument in jest

My use case layer in nestjs look like below export class AddModuleUseCases { constructor( private readonly logger: ILogger, private readonly i18n: I18nService, private readonly ...
user3354853's user avatar
0 votes
1 answer
22 views

Accessing imported modules in jest

I am using this format to import modules in a ts project. import { Configs } from '@configs' Based on using this setting in tsconfig.json "paths": { "@configs": ["...
mystride's user avatar
  • 105

1
2 3 4 5
34