diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index af86996795..b7b60f2e53 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -13,6 +13,7 @@ // Ahn // Josh Goldberg // Bradley Ayers +// Martin Hochel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -795,6 +796,7 @@ declare namespace jest { type SnapshotUpdateState = 'all' | 'new' | 'none'; + // https://facebook.github.io/jest/docs/en/cli.html#options interface GlobalConfig { bail: boolean; collectCoverage: boolean; @@ -824,6 +826,7 @@ declare namespace jest { watchman: boolean; } + // https://facebook.github.io/jest/docs/en/configuration.html#options interface ProjectConfig { automock: boolean; browser: boolean; @@ -863,7 +866,7 @@ declare namespace jest { testRunner: string; testURL: string; timers: 'real' | 'fake'; - transform: Array<[string, Path]>; + transform: {[regexpGlob: string]: string}; transformIgnorePatterns: Glob[]; unmockedModulePathPatterns: Maybe; watchPathIgnorePatterns: string[]; diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index a90a7a9e5a..b8dff71522 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -731,3 +731,24 @@ test('moduleName 2', () => { const moduleName = require('../moduleName'); expect(moduleName()).toEqual(2); }); + +// Jest config +{ +// tslint:disable-next-line:no-var-requires +const {defaults} = require('jest-config') as {defaults: jest.ProjectConfig}; + +const config: Partial = { + transform: { + '^.+\\.(ts|tsx)$': 'ts-jest' + }, + testMatch: [ + ...defaults.testMatch, + '**/__tests__/**/*.ts?(x)', + '**/?(*.)+(spec|test).ts?(x)' + ], + moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'], + globals: { + 'ts-jest': {} + } +}; +}