fix(jest): fix ProjectConfig.transform type

This commit is contained in:
Martin Hochel
2018-06-06 00:43:41 +02:00
parent f3c27f8b48
commit b3e178b990
2 changed files with 25 additions and 1 deletions
+4 -1
View File
@@ -13,6 +13,7 @@
// Ahn <https://github.com/AhnpGit>
// Josh Goldberg <https://github.com/joshuakgoldberg>
// Bradley Ayers <https://github.com/bradleyayers>
// Martin Hochel <https://github.com/hotell>
// 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<string[]>;
watchPathIgnorePatterns: string[];
+21
View File
@@ -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<jest.ProjectConfig> = {
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest'
},
testMatch: [
...defaults.testMatch,
'**/__tests__/**/*.ts?(x)',
'**/?(*.)+(spec|test).ts?(x)'
],
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
globals: {
'ts-jest': {}
}
};
}