Well, using ts-jest
27.x.x
, I could access the utils
helper by require('ts-jest/utils')
, and as you can see in the below picture, it was present in the ts-jest dependency folder:
But in a newer project using ts-jest
28.x.x
, when I try to import that, this is the result:
And this is the ts-jest dependency folder:
我现在应该怎么做才能使用这些助手?
See 测试助手 https://kulshekhar.github.io/ts-jest/docs/27.1/guides/test-helpers文档关于mocked
测试助手:
此功能现已弃用,并将在28.0.0。该功能已集成到jest-mock
包作为 Jest 的一部分27.4.0, see https://github.com/facebook/jest/pull/12089 https://github.com/facebook/jest/pull/12089。请使用来自jest-mock
反而。
你应该使用jest.mocked(项目:T,深度= false) https://jestjs.io/docs/27.x/jest-object#jestmockedtitem-t-deep--false代替import { mocked } from 'ts-jest/utils'
From ts-jest
28.0.0,他们删除ts-jest/utils
子路径导出。看到这个issue https://github.com/kulshekhar/ts-jest/pull/3334
我们正在出口所有东西index.ts
so utils
现在可以删除了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)