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

admin2025-04-15  1

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.

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.

Share Improve this question asked Feb 4 at 13:01 Janos VincellerJanos Vinceller 1,28612 silver badges28 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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();
转载请注明原文地址:http://www.anycun.com/QandA/1744717502a86649.html