Skip to content

Commit 4526392

Browse files
authoredMay 4, 2020
feat(config): define 'ts-jest' on ConfigGlobals interface of @jest/types (#1592)
1 parent 526265d commit 4526392

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed
 

‎docs/user/config/index.md

+17
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,23 @@ module.exports = {
181181

182182
</div></div>
183183

184+
#### IDE `ts-jest` config suggestion
185+
186+
To ultilize IDE suggestion, you can use `JSDOC` to provide suggested `ts-jest` configs for your Jest config:
187+
188+
```js
189+
/** @type {import('@jest/types').Config.InitialOptions} */
190+
/** @typedef {import('ts-jest')} */
191+
module.exports = {
192+
// [...]
193+
globals: {
194+
'ts-jest': {
195+
// ts-jest configuration goes here and your IDE will suggest which configs when typing
196+
}
197+
}
198+
};
199+
```
200+
184201
### Options
185202

186203
All options have default values which should fit most of the projects. Click on the option's name to see details and example(s).

‎e2e/__helpers__/test-case/runtime.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function run(name: string, options: RunTestOptions = {}): RunResult {
9292
merge(extraConfig, options.jestConfig)
9393
}
9494
if (options.tsJestConfig) {
95-
const globalConfig: any = extraConfig.globals || (extraConfig.globals = {})
95+
const globalConfig: any = extraConfig.globals || (extraConfig.globals = {'ts-jest': {}})
9696
const tsJestConfig = globalConfig['ts-jest'] || (globalConfig['ts-jest'] = {})
9797
merge(tsJestConfig, options.tsJestConfig)
9898
}

‎package-lock.json

+4-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ import { Deprecateds, interpolate } from './util/messages'
1111
import { mocked as mockedCore } from './util/testing'
1212
import { VersionCheckers } from './util/version-checkers'
1313

14+
declare module '@jest/types' {
15+
// eslint-disable-next-line @typescript-eslint/no-namespace
16+
namespace Config {
17+
interface ConfigGlobals {
18+
'ts-jest': TsJestGlobalOptions
19+
}
20+
}
21+
}
22+
1423
// deprecate helpers
1524
const warn = rootLogger.child({ [LogContexts.logLevel]: LogLevels.warn })
1625
const helperMoved = <T extends (...args: any[]) => any>(name: string, helper: T) =>

0 commit comments

Comments
 (0)
Please sign in to comment.