diff --git a/docs/user/config/index.md b/docs/user/config/index.md index 5e06e4fba9..55faf32029 100644 --- a/docs/user/config/index.md +++ b/docs/user/config/index.md @@ -181,6 +181,23 @@ module.exports = { +#### IDE `ts-jest` config suggestion + +To ultilize IDE suggestion, you can use `JSDOC` to provide suggested `ts-jest` configs for your Jest config: + +```js +/** @type {import('@jest/types').Config.InitialOptions} */ +/** @typedef {import('ts-jest')} */ +module.exports = { + // [...] + globals: { + 'ts-jest': { + // ts-jest configuration goes here and your IDE will suggest which configs when typing + } + } +}; +``` + ### Options All options have default values which should fit most of the projects. Click on the option's name to see details and example(s). diff --git a/e2e/__helpers__/test-case/runtime.ts b/e2e/__helpers__/test-case/runtime.ts index 3e4bdb5f7f..78fbeae94d 100644 --- a/e2e/__helpers__/test-case/runtime.ts +++ b/e2e/__helpers__/test-case/runtime.ts @@ -92,7 +92,7 @@ export function run(name: string, options: RunTestOptions = {}): RunResult { merge(extraConfig, options.jestConfig) } if (options.tsJestConfig) { - const globalConfig: any = extraConfig.globals || (extraConfig.globals = {}) + const globalConfig: any = extraConfig.globals || (extraConfig.globals = {'ts-jest': {}}) const tsJestConfig = globalConfig['ts-jest'] || (globalConfig['ts-jest'] = {}) merge(tsJestConfig, options.tsJestConfig) } diff --git a/package-lock.json b/package-lock.json index efc8ed5c8d..4d4dff514d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4978,12 +4978,6 @@ "isobject": "^3.0.1" } }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, "is-regex": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", @@ -8451,13 +8445,10 @@ "dev": true }, "run-async": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.0.tgz", - "integrity": "sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg==", - "dev": true, - "requires": { - "is-promise": "^2.1.0" - } + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "dev": true }, "run-node": { "version": "1.0.0", diff --git a/src/index.ts b/src/index.ts index 9b427c9329..461eb04e88 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,6 +11,15 @@ import { Deprecateds, interpolate } from './util/messages' import { mocked as mockedCore } from './util/testing' import { VersionCheckers } from './util/version-checkers' +declare module '@jest/types' { + // eslint-disable-next-line @typescript-eslint/no-namespace + namespace Config { + interface ConfigGlobals { + 'ts-jest': TsJestGlobalOptions + } + } +} + // deprecate helpers const warn = rootLogger.child({ [LogContexts.logLevel]: LogLevels.warn }) const helperMoved = any>(name: string, helper: T) =>