Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning appears after starting jest - Importing "setup-jest.js" directly is deprecated

After starting Jest (in my case version 29.7.0), the following message appears:

Importing "setup-jest.js" directly is deprecated. The file "setup-jest.js" will be removed in the future.
Please use "setupZoneTestEnv" function instead. Example:

// setup-jest.ts
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';

setupZoneTestEnv();

What's the problem? How can I fix this?

I already removed the setupFilesAfterEnv property from jest.config.js that brought up another message.

like image 608
Janos Vinceller Avatar asked Nov 03 '25 08:11

Janos Vinceller


1 Answers

The solution was to change this line in setup-jest.ts:

import 'jest-preset-angular/setup-jest';

to this solution (so please delete the line above:

import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
setupZoneTestEnv();
like image 88
Janos Vinceller Avatar answered Nov 04 '25 23:11

Janos Vinceller