Janos Vinceller
Janos Vinceller

Reputation: 1266

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.

Upvotes: 0

Views: 437

Answers (1)

Janos Vinceller
Janos Vinceller

Reputation: 1266

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();

Upvotes: 0

Related Questions