From 55e69f12f65d678962c3087fca7673992f5f1b26 Mon Sep 17 00:00:00 2001 From: Ahn <27772165+ahnpnl@users.noreply.github.com> Date: Tue, 30 Nov 2021 08:28:43 +0100 Subject: [PATCH] refactor(utils): deprecate `mocked` util function (#3102) --- .github/workflows/ci.yml | 1 + src/utils/testing.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fad5ff93b..465521e6f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,7 @@ jobs: run: npm run test -- --coverage && cat ./coverage/lcov.info env: CI: true + DISABLE_MOCKED_WARNING: true - name: Coveralls parallel uses: coverallsapp/github-action@master with: diff --git a/src/utils/testing.ts b/src/utils/testing.ts index 5b6d7a0f8f..a9783348e8 100644 --- a/src/utils/testing.ts +++ b/src/utils/testing.ts @@ -1,3 +1,12 @@ +if (!process.env.DISABLE_MOCKED_WARNING) { + console.warn( + '\n`mocked` util function is now deprecated and has been moved to Jest repository,' + + ' see https://github.com/facebook/jest/pull/12089. In `ts-jest` v28.0.0, `mocked` function will be completely removed.' + + ' Users are encouraged to use to Jest v27.4.0 or above to have `mocked` function available from `jest-mock`. ' + + 'One can disable this warning by setting environment variable process.env.DISABLE_MOCKED_WARNING=true\n', + ) +} + // eslint-disable-next-line @typescript-eslint/no-explicit-any export type MockableFunction = (...args: any[]) => any export type MethodKeysOf = { [K in keyof T]: T[K] extends MockableFunction ? K : never }[keyof T]