Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): define 'ts-jest' on ConfigGlobals interface in @jest/types #1592

Merged
merged 1 commit into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/user/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion e2e/__helpers__/test-case/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
17 changes: 4 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down