Questions tagged [ts-jest]

A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript.

1505 questions
20
votes
5 answers

The current testing environment is not configured to support act(...) - @testing-library/react

I'm trying to upgrade my project to React 18, everything works in dev and production mode in the browser. But after upgrading to the latest version of @testing-library/react some of my unit tests are failing and a lot of them are logging the…
MLyck
  • 4,959
  • 13
  • 43
  • 74
19
votes
7 answers

"ReferenceError: structuredClone is not defined" using jest with nodejs & typescript

I'm running tests with jest in a simple NodeJS app that uses typescript. My test is throwing an error: ReferenceError: structuredClone is not defined. I'm not getting any linter errors and the code compiles fine normally. const…
JimmyTheCode
  • 3,783
  • 7
  • 29
  • 71
19
votes
5 answers

NestJS Jest cannot find module with absolute path

I have a quite new NestJS application. I'm trying to run unit tests, but they keep failing due to 'cannot find module..' when using absolute paths ("src/users/..."), but works when using relative paths ("./users/.."). Is there anything wrong with my…
Chris Eikrem
  • 496
  • 1
  • 5
  • 20
18
votes
4 answers

Jest encountered an unexpected token + react markdown

I'm getting an error when trying to run my test file (I'm using react typescript) ● Test suite failed to run Jest encountered an unexpected token Jest failed to parse a file. This happens e.g. when your code or its dependencies use…
ng-someone
  • 321
  • 2
  • 9
18
votes
4 answers

Uncaught TypeError: Cannot read properties of undefined (reading 'isBatchingLegacy')

I am trying to test a react typescript project using jest but it's giving a confusing error: Error image Here is my package.json: "dependencies": { "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^12.1.5", …
Sadman Yasar Sayem
  • 851
  • 1
  • 5
  • 10
17
votes
2 answers

Vuetify Jest Unknown custom element

I am writing unit tests for my project, using Jest. Project is based on Vue, Vuetify (1.5) and TypeScript (and vue-property-decorator). I have basic wrapper for . It looks like this: