Skip to content
Permalink
Browse files

feat(config): define 'ts-jest' on `ConfigGlobals` interface of `@jest…

…/types` (#1592)
  • Loading branch information
ahnpnl committed May 4, 2020
1 parent 526265d commit 452639242d7f59502bda7aa94b81735f9c9ad203
Showing with 31 additions and 14 deletions.
  1. +17 −0 docs/user/config/index.md
  2. +1 −1 e2e/__helpers__/test-case/runtime.ts
  3. +4 −13 package-lock.json
  4. +9 −0 src/index.ts
@@ -181,6 +181,23 @@ module.exports = {

</div></div>

#### 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).
@@ -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)
}

Some generated files are not rendered by default. Learn more.

@@ -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 = <T extends (...args: any[]) => any>(name: string, helper: T) =>

0 comments on commit 4526392

Please sign in to comment.
You can’t perform that action at this time.