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:

What should I do now to use those helpers?
See Test helpers doc about the mocked test helper:
This function is now deprecated and will be removed in 28.0.0. The function has been integrated into
jest-mockpackage as a part of Jest 27.4.0, see https://github.com/facebook/jest/pull/12089. Please use the one fromjest-mockinstead.
You should use jest.mocked(item: T, deep = false) instead of import { mocked } from 'ts-jest/utils'
From ts-jest 28.0.0, they remove ts-jest/utils sub path export. See this issue
We are exporting everything from
index.tssoutilsnow can be removed.
Replace
import { mocked } from "ts-jest/utils";
with
import { mocked } from "jest-mock";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With