最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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,26612 silver badges27 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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();
发布评论

评论列表(0)

  1. 暂无评论