From 24944e6090f39ba4fa94b4e02171563f799d0277 Mon Sep 17 00:00:00 2001 From: cpojer Date: Fri, 21 Apr 2017 19:24:03 -0700 Subject: [PATCH] Remove `Config` type. --- packages/babel-jest/src/index.js | 4 +- .../src/__tests__/SearchSource-test.js | 30 ++--- .../jest-cli/src/__tests__/runJest-test.js | 104 ------------------ .../src/__tests__/normalize-test.js | 76 ++++++------- packages/jest-config/src/constants.js | 2 + packages/jest-config/src/index.js | 60 +++++----- packages/jest-config/src/normalize.js | 3 +- packages/jest-environment-jsdom/src/index.js | 4 +- packages/jest-environment-node/src/index.js | 4 +- packages/jest-jasmine2/src/index.js | 6 +- packages/jest-jasmine2/src/jest-expect.js | 3 +- .../jest-jasmine2/src/setup-jest-globals.js | 4 +- .../src/__tests__/DependencyResolver-test.js | 2 +- .../src/__mocks__/createRuntime.js | 2 +- types/Config.js | 60 ---------- types/Environment.js | 4 +- 16 files changed, 103 insertions(+), 265 deletions(-) delete mode 100644 packages/jest-cli/src/__tests__/runJest-test.js diff --git a/packages/babel-jest/src/index.js b/packages/babel-jest/src/index.js index e7c25546c87e..bcbe7a4070b1 100644 --- a/packages/babel-jest/src/index.js +++ b/packages/babel-jest/src/index.js @@ -10,7 +10,7 @@ 'use strict'; -import type {Config, Path} from 'types/Config'; +import type {Path, ProjectConfig} from 'types/Config'; import type {TransformOptions} from 'types/Transform'; const crypto = require('crypto'); @@ -104,7 +104,7 @@ const createTransformer = (options: any) => { process( src: string, filename: Path, - config: Config, + config: ProjectConfig, transformOptions: TransformOptions, ): string { if (!babel) { diff --git a/packages/jest-cli/src/__tests__/SearchSource-test.js b/packages/jest-cli/src/__tests__/SearchSource-test.js index 6e9120e354a1..751d199b290e 100644 --- a/packages/jest-cli/src/__tests__/SearchSource-test.js +++ b/packages/jest-cli/src/__tests__/SearchSource-test.js @@ -46,7 +46,7 @@ describe('SearchSource', () => { name, rootDir: '.', roots: [], - }).config; + }).options; return Runtime.createContext(config, {maxWorkers}).then(context => { searchSource = new SearchSource(context); }); @@ -62,7 +62,7 @@ describe('SearchSource', () => { roots: [], testMatch: null, testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$', - }).config; + }).options; return Runtime.createContext(config, { maxWorkers, }).then(context => { @@ -100,7 +100,7 @@ describe('SearchSource', () => { }); it('finds tests matching a pattern via testRegex', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ moduleFileExtensions: ['js', 'jsx', 'txt'], name, rootDir, @@ -121,7 +121,7 @@ describe('SearchSource', () => { }); it('finds tests matching a pattern via testMatch', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ moduleFileExtensions: ['js', 'jsx', 'txt'], name, rootDir, @@ -142,7 +142,7 @@ describe('SearchSource', () => { }); it('finds tests matching a JS regex pattern', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ moduleFileExtensions: ['js', 'jsx'], name, rootDir, @@ -161,7 +161,7 @@ describe('SearchSource', () => { }); it('finds tests matching a JS glob pattern', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ moduleFileExtensions: ['js', 'jsx'], name, rootDir, @@ -180,7 +180,7 @@ describe('SearchSource', () => { }); it('finds tests with default file extensions using testRegex', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ name, rootDir, testMatch: null, @@ -198,7 +198,7 @@ describe('SearchSource', () => { }); it('finds tests with default file extensions using testMatch', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ name, rootDir, testMatch, @@ -216,7 +216,7 @@ describe('SearchSource', () => { }); it('finds tests with similar but custom file extensions', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ moduleFileExtensions: ['jsx'], name, rootDir, @@ -231,7 +231,7 @@ describe('SearchSource', () => { }); it('finds tests with totally custom foobar file extensions', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ moduleFileExtensions: ['foobar'], name, rootDir, @@ -246,7 +246,7 @@ describe('SearchSource', () => { }); it('finds tests with many kinds of file extensions', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ moduleFileExtensions: ['js', 'jsx'], name, rootDir, @@ -264,7 +264,7 @@ describe('SearchSource', () => { }); it('finds tests using a regex only', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ name, rootDir, testMatch: null, @@ -282,7 +282,7 @@ describe('SearchSource', () => { }); it('finds tests using a glob only', () => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ name, rootDir, testMatch, @@ -314,7 +314,7 @@ describe('SearchSource', () => { const rootPath = path.join(rootDir, 'root.js'); beforeEach(done => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ name: 'SearchSource-findRelatedTests-tests', rootDir, }); @@ -345,7 +345,7 @@ describe('SearchSource', () => { describe('findRelatedTestsFromPattern', () => { beforeEach(done => { - const {config} = normalizeConfig({ + const {options: config} = normalizeConfig({ moduleFileExtensions: ['js', 'jsx', 'foobar'], name, rootDir, diff --git a/packages/jest-cli/src/__tests__/runJest-test.js b/packages/jest-cli/src/__tests__/runJest-test.js deleted file mode 100644 index 2d36e4c4c0b1..000000000000 --- a/packages/jest-cli/src/__tests__/runJest-test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @emails oncall+jsinfra - */ - -'use strict'; - -const runJest = require('../runJest'); -const TestWatcher = require('../TestWatcher'); -const normalizeConfig = require('jest-config').normalize; -const path = require('path'); - -const skipOnWindows = require('skipOnWindows'); -skipOnWindows.suite(); - -jest.mock('../TestRunner', () => { - return class TestRunner { - runTests() { - return Promise.resolve({ - testResults: ['/path.js'], - }); - } - }; -}); - -jest.mock('../SearchSource', () => { - const SearchSource = require.requireActual('../SearchSource'); - SearchSource.prototype.getTestPaths = function() { - return Promise.resolve({ - stats: {}, - tests: [ - { - context: this._context, - path: '/path.js', - }, - ], - total: 1, - }); - }; - return SearchSource; -}); - -jest.mock('../TestSequencer', () => { - const TestSequencer = require.requireActual('../TestSequencer'); - TestSequencer.prototype.sort = jest.fn(tests => tests); - TestSequencer.prototype.cacheResults = jest.fn(); - return TestSequencer; -}); - -let config; -let hasteFS; -const maxWorkers = 2; -const rootDir = path.resolve(__dirname, 'test_root'); - -if (process.platform !== 'win32') { - beforeEach(() => { - config = normalizeConfig({ - rootDir, - roots: [], - }).config; - const Runtime = require('jest-runtime'); - return Runtime.createContext(config, {maxWorkers}).then(hasteMap => { - hasteFS = hasteMap.hasteFS; - }); - }); -} - -test('passes updateSnapshot to context.config', async () => { - const contexts = [ - { - config, - hasteFS, - }, - { - config: { - rootDir, - roots: [], - testPathIgnorePatterns: [], - }, - hasteFS, - }, - ]; - const noop = () => {}; - const argv = {}; - const pipe = process.stdout; - const testWatcher = new TestWatcher({isWatchMode: true}); - await runJest( - { - updateSnapshot: true, - }, - contexts, - argv, - pipe, - testWatcher, - noop, - noop, - ); - expect(contexts.every(({config}) => config.updateSnapshot)).toBe(true); -}); diff --git a/packages/jest-config/src/__tests__/normalize-test.js b/packages/jest-config/src/__tests__/normalize-test.js index d3daed5a8a7e..a5107e51fb87 100644 --- a/packages/jest-config/src/__tests__/normalize-test.js +++ b/packages/jest-config/src/__tests__/normalize-test.js @@ -53,7 +53,7 @@ it('picks a name based on the rootDir', () => { expect( normalize({ rootDir, - }).config.name, + }).options.name, ).toBe(expected); }); @@ -62,7 +62,7 @@ it('keeps custom names based on the rootDir', () => { normalize({ name: 'custom-name', rootDir: '/root/path/foo', - }).config.name, + }).options.name, ).toBe('custom-name'); }); @@ -75,7 +75,7 @@ it('sets coverageReporters correctly when argv.json is set', () => { { json: true, }, - ).config.coverageReporters, + ).options.coverageReporters, ).toEqual(['json', 'lcov', 'clover']); }); @@ -91,7 +91,7 @@ describe('automock', () => { it('falsy automock is not overwritten', () => { const consoleWarn = console.warn; console.warn = jest.fn(); - const {config} = normalize({ + const {options: config} = normalize({ automock: false, rootDir: '/root/path/foo', }); @@ -104,7 +104,7 @@ describe('automock', () => { describe('browser', () => { it('falsy browser is not overwritten', () => { - const {config} = normalize({ + const {options: config} = normalize({ browser: true, rootDir: '/root/path/foo', }); @@ -115,7 +115,7 @@ describe('browser', () => { describe('collectCoverageOnlyFrom', () => { it('normalizes all paths relative to rootDir', () => { - const {config} = normalize( + const {options: config} = normalize( { collectCoverageOnlyFrom: { 'bar/baz': true, @@ -134,7 +134,7 @@ describe('collectCoverageOnlyFrom', () => { }); it('does not change absolute paths', () => { - const {config} = normalize({ + const {options: config} = normalize({ collectCoverageOnlyFrom: { '/an/abs/path': true, '/another/abs/path': true, @@ -150,7 +150,7 @@ describe('collectCoverageOnlyFrom', () => { }); it('substitutes tokens', () => { - const {config} = normalize({ + const {options: config} = normalize({ collectCoverageOnlyFrom: { '/bar/baz': true, }, @@ -166,7 +166,7 @@ describe('collectCoverageOnlyFrom', () => { function testPathArray(key) { it('normalizes all paths relative to rootDir', () => { - const {config} = normalize( + const {options: config} = normalize( { [key]: ['bar/baz', 'qux/quux/'], rootDir: '/root/path/foo', @@ -178,7 +178,7 @@ function testPathArray(key) { }); it('does not change absolute paths', () => { - const {config} = normalize({ + const {options: config} = normalize({ [key]: ['/an/abs/path', '/another/abs/path'], rootDir: '/root/path/foo', }); @@ -187,7 +187,7 @@ function testPathArray(key) { }); it('substitutes tokens', () => { - const {config} = normalize({ + const {options: config} = normalize({ [key]: ['/bar/baz'], rootDir: '/root/path/foo', }); @@ -208,7 +208,7 @@ describe('transform', () => { }); it('normalizes the path', () => { - const {config} = normalize( + const {options: config} = normalize( { rootDir: '/root/', transform: { @@ -236,7 +236,7 @@ describe('haste', () => { }); it('normalizes the path for hasteImplModulePath', () => { - const {config} = normalize({ + const {options: config} = normalize({ haste: { hasteImplModulePath: '/hasteImpl.js', }, @@ -260,7 +260,7 @@ describe('setupTestFrameworkScriptFile', () => { }); it('normalizes the path according to rootDir', () => { - const {config} = normalize( + const {options: config} = normalize( { rootDir: '/root/path/foo', setupTestFrameworkScriptFile: 'bar/baz', @@ -272,7 +272,7 @@ describe('setupTestFrameworkScriptFile', () => { }); it('does not change absolute paths', () => { - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root/path/foo', setupTestFrameworkScriptFile: '/an/abs/path', }); @@ -281,7 +281,7 @@ describe('setupTestFrameworkScriptFile', () => { }); it('substitutes tokens', () => { - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root/path/foo', setupTestFrameworkScriptFile: '/bar/baz', }); @@ -294,7 +294,7 @@ describe('coveragePathIgnorePatterns', () => { it('does not normalize paths relative to rootDir', () => { // This is a list of patterns, so we can't assume any of them are // directories - const {config} = normalize( + const {options: config} = normalize( { coveragePathIgnorePatterns: ['bar/baz', 'qux/quux'], rootDir: '/root/path/foo', @@ -311,7 +311,7 @@ describe('coveragePathIgnorePatterns', () => { it('does not normalize trailing slashes', () => { // This is a list of patterns, so we can't assume any of them are // directories - const {config} = normalize({ + const {options: config} = normalize({ coveragePathIgnorePatterns: ['bar/baz', 'qux/quux/'], rootDir: '/root/path/foo', }); @@ -323,7 +323,7 @@ describe('coveragePathIgnorePatterns', () => { }); it('substitutes tokens', () => { - const {config} = normalize({ + const {options: config} = normalize({ coveragePathIgnorePatterns: ['hasNoToken', '/hasAToken'], rootDir: '/root/path/foo', }); @@ -339,7 +339,7 @@ describe('testPathIgnorePatterns', () => { it('does not normalize paths relative to rootDir', () => { // This is a list of patterns, so we can't assume any of them are // directories - const {config} = normalize( + const {options: config} = normalize( { rootDir: '/root/path/foo', testPathIgnorePatterns: ['bar/baz', 'qux/quux'], @@ -356,7 +356,7 @@ describe('testPathIgnorePatterns', () => { it('does not normalize trailing slashes', () => { // This is a list of patterns, so we can't assume any of them are // directories - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root/path/foo', testPathIgnorePatterns: ['bar/baz', 'qux/quux/'], }); @@ -368,7 +368,7 @@ describe('testPathIgnorePatterns', () => { }); it('substitutes tokens', () => { - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root/path/foo', testPathIgnorePatterns: ['hasNoToken', '/hasAToken'], }); @@ -384,7 +384,7 @@ describe('modulePathIgnorePatterns', () => { it('does not normalize paths relative to rootDir', () => { // This is a list of patterns, so we can't assume any of them are // directories - const {config} = normalize( + const {options: config} = normalize( { modulePathIgnorePatterns: ['bar/baz', 'qux/quux'], rootDir: '/root/path/foo', @@ -401,7 +401,7 @@ describe('modulePathIgnorePatterns', () => { it('does not normalize trailing slashes', () => { // This is a list of patterns, so we can't assume any of them are // directories - const {config} = normalize({ + const {options: config} = normalize({ modulePathIgnorePatterns: ['bar/baz', 'qux/quux/'], rootDir: '/root/path/foo', }); @@ -413,7 +413,7 @@ describe('modulePathIgnorePatterns', () => { }); it('substitutes tokens', () => { - const {config} = normalize({ + const {options: config} = normalize({ modulePathIgnorePatterns: ['hasNoToken', '/hasAToken'], rootDir: '/root/path/foo', }); @@ -427,7 +427,7 @@ describe('modulePathIgnorePatterns', () => { describe('testRunner', () => { it('defaults to Jasmine 2', () => { - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root/path/foo', }); @@ -435,7 +435,7 @@ describe('testRunner', () => { }); it('can be changed to jasmine1', () => { - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root/path/foo', testRunner: 'jasmine1', }); @@ -444,7 +444,7 @@ describe('testRunner', () => { }); it('is overwritten by argv', () => { - const {config} = normalize( + const {options: config} = normalize( { rootDir: '/root/path/foo', }, @@ -473,7 +473,7 @@ describe('testEnvironment', () => { }); it('resolves to an environment and prefers jest-environment-`name`', () => { - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root', testEnvironment: 'jsdom', }); @@ -503,7 +503,7 @@ describe('babel-jest', () => { }); it('correctly identifies and uses babel-jest', () => { - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root', }); @@ -523,7 +523,7 @@ describe('babel-jest', () => { it('uses babel-jest if babel-jest is explicitly specified in a custom transform config', () => { const customJSPattern = '^.+\\.js$'; - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root', transform: { [customJSPattern]: 'babel-jest', @@ -545,7 +545,7 @@ describe('babel-jest', () => { it(`doesn't use babel-jest if its not available`, () => { Resolver.findNodeModule.mockImplementation(() => null); - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root', }); @@ -556,7 +556,7 @@ describe('babel-jest', () => { it('uses regenerator if babel-jest is explicitly specified', () => { const ROOT_DIR = '' + path.sep; - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root', transform: { [DEFAULT_JS_PATTERN]: ROOT_DIR + Resolver.findNodeModule('babel-jest'), @@ -587,7 +587,7 @@ describe('Upgrade help', () => { }); it('logs a warning when `scriptPreprocessor` and/or `preprocessorIgnorePatterns` are used', () => { - const {config, hasDeprecationWarnings} = normalize({ + const {options: config, hasDeprecationWarnings} = normalize({ preprocessorIgnorePatterns: ['bar/baz', 'qux/quux'], rootDir: '/root/path/foo', scriptPreprocessor: 'bar/baz', @@ -609,7 +609,7 @@ describe('Upgrade help', () => { describe('testMatch', () => { it('testMatch default not applied if testRegex is set', () => { - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root', testRegex: '.*', }); @@ -618,7 +618,7 @@ describe('testMatch', () => { }); it('testRegex default not applied if testMatch is set', () => { - const {config} = normalize({ + const {options: config} = normalize({ rootDir: '/root', testMatch: ['**/*.js'], }); @@ -673,7 +673,7 @@ describe('preset', () => { }); test('merges with config', () => { - const {config} = normalize({ + const {options: config} = normalize({ moduleNameMapper: {a: 'a'}, modulePathIgnorePatterns: ['a'], preset: 'react-native', @@ -716,7 +716,7 @@ describe('preset without setupFiles', () => { }); it('should normalize setupFiles correctly', () => { - const {config} = normalize({ + const {options: config} = normalize({ preset: 'react-native', rootDir: '/root/path/foo', setupFiles: ['a'], diff --git a/packages/jest-config/src/constants.js b/packages/jest-config/src/constants.js index ff4cfa3efd2d..af9b0caa8939 100644 --- a/packages/jest-config/src/constants.js +++ b/packages/jest-config/src/constants.js @@ -4,6 +4,8 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow */ 'use strict'; diff --git a/packages/jest-config/src/index.js b/packages/jest-config/src/index.js index 9a2d1d8b2510..4a82e2ce5e16 100644 --- a/packages/jest-config/src/index.js +++ b/packages/jest-config/src/index.js @@ -10,7 +10,7 @@ 'use strict'; -import type {Config, GlobalConfig, ProjectConfig} from 'types/Config'; +import type {GlobalConfig, ProjectConfig} from 'types/Config'; const path = require('path'); const loadFromFile = require('./loadFromFile'); @@ -28,8 +28,8 @@ async function readConfig( hasDeprecationWarnings: boolean, }> { const rawConfig = await readRawConfig(argv, packageRoot); - const {config, hasDeprecationWarnings} = normalize(rawConfig, argv); - const {globalConfig, projectConfig} = getConfigs(setFromArgv(config, argv)); + const {options, hasDeprecationWarnings} = normalize(rawConfig, argv); + const {globalConfig, projectConfig} = getConfigs(setFromArgv(options, argv)); return { config: projectConfig, globalConfig, @@ -64,37 +64,37 @@ const readRawConfig = (argv, root) => { }; const getConfigs = ( - config: Config, + options, ): {globalConfig: GlobalConfig, projectConfig: ProjectConfig} => { return { globalConfig: Object.freeze({ - bail: config.bail, - collectCoverage: config.collectCoverage, - collectCoverageFrom: config.collectCoverageFrom, - collectCoverageOnlyFrom: config.collectCoverageOnlyFrom, - coverageDirectory: config.coverageDirectory, - coveragePathIgnorePatterns: config.coveragePathIgnorePatterns, - coverageReporters: config.coverageReporters, - coverageThreshold: config.coverageThreshold, - expand: config.expand, - forceExit: config.forceExit, - logHeapUsage: config.logHeapUsage, - logTransformErrors: config.logTransformErrors, - mapCoverage: config.mapCoverage, - noStackTrace: config.noStackTrace, - notify: config.notify, - replname: config.replname, - rootDir: config.rootDir, - silent: config.silent, - testNamePattern: config.testNamePattern, - testResultsProcessor: config.testResultsProcessor, - updateSnapshot: config.updateSnapshot, - useStderr: config.useStderr, - verbose: config.verbose, - watch: config.watch, - watchman: config.watchman, + bail: options.bail, + collectCoverage: options.collectCoverage, + collectCoverageFrom: options.collectCoverageFrom, + collectCoverageOnlyFrom: options.collectCoverageOnlyFrom, + coverageDirectory: options.coverageDirectory, + coveragePathIgnorePatterns: options.coveragePathIgnorePatterns, + coverageReporters: options.coverageReporters, + coverageThreshold: options.coverageThreshold, + expand: options.expand, + forceExit: options.forceExit, + logHeapUsage: options.logHeapUsage, + logTransformErrors: options.logTransformErrors, + mapCoverage: options.mapCoverage, + noStackTrace: options.noStackTrace, + notify: options.notify, + replname: options.replname, + rootDir: options.rootDir, + silent: options.silent, + testNamePattern: options.testNamePattern, + testResultsProcessor: options.testResultsProcessor, + updateSnapshot: options.updateSnapshot, + useStderr: options.useStderr, + verbose: options.verbose, + watch: options.watch, + watchman: options.watchman, }), - projectConfig: config, + projectConfig: options, }; }; diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index e65d9d56683f..326b098b54a4 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -4,6 +4,7 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * * @flow */ @@ -407,8 +408,8 @@ function normalize(config: InitialConfig, argv: Object = {}) { } return { - config: _replaceRootDirTags(newConfig.rootDir, newConfig), hasDeprecationWarnings, + options: _replaceRootDirTags(newConfig.rootDir, newConfig), }; } diff --git a/packages/jest-environment-jsdom/src/index.js b/packages/jest-environment-jsdom/src/index.js index cd7517c9eeb8..aba34f981380 100644 --- a/packages/jest-environment-jsdom/src/index.js +++ b/packages/jest-environment-jsdom/src/index.js @@ -8,7 +8,7 @@ */ 'use strict'; -import type {Config} from 'types/Config'; +import type {ProjectConfig} from 'types/Config'; import type {Global} from 'types/Global'; import type {Script} from 'vm'; import type {ModuleMocker} from 'jest-mock'; @@ -23,7 +23,7 @@ class JSDOMEnvironment { global: ?Global; moduleMocker: ?ModuleMocker; - constructor(config: Config): void { + constructor(config: ProjectConfig): void { // lazy require this.document = require('jsdom').jsdom(/* markup */ undefined, { url: config.testURL, diff --git a/packages/jest-environment-node/src/index.js b/packages/jest-environment-node/src/index.js index 6328c64bd068..945d314aefea 100644 --- a/packages/jest-environment-node/src/index.js +++ b/packages/jest-environment-node/src/index.js @@ -9,7 +9,7 @@ */ 'use strict'; -import type {Config} from 'types/Config'; +import type {ProjectConfig} from 'types/Config'; import type {Global} from 'types/Global'; import type {Script} from 'vm'; import type {ModuleMocker} from 'jest-mock'; @@ -25,7 +25,7 @@ class NodeEnvironment { global: ?Global; moduleMocker: ?ModuleMocker; - constructor(config: Config) { + constructor(config: ProjectConfig) { this.context = vm.createContext(); const global = (this.global = vm.runInContext('this', this.context)); global.global = global; diff --git a/packages/jest-jasmine2/src/index.js b/packages/jest-jasmine2/src/index.js index 980a8d2038bc..40b8891baebb 100644 --- a/packages/jest-jasmine2/src/index.js +++ b/packages/jest-jasmine2/src/index.js @@ -71,9 +71,9 @@ function jasmine2( env.addReporter(reporter); - runtime.requireInternalModule(path.resolve(__dirname, './jest-expect.js'))( - config, - ); + runtime.requireInternalModule(path.resolve(__dirname, './jest-expect.js'))({ + expand: globalConfig.expand, + }); const snapshotState = runtime.requireInternalModule( path.resolve(__dirname, './setup-jest-globals.js'), diff --git a/packages/jest-jasmine2/src/jest-expect.js b/packages/jest-jasmine2/src/jest-expect.js index 448db9e8a451..8de270e03c0a 100644 --- a/packages/jest-jasmine2/src/jest-expect.js +++ b/packages/jest-jasmine2/src/jest-expect.js @@ -9,7 +9,6 @@ */ 'use strict'; -import type {Config} from 'types/Config'; import type {RawMatcherFn} from 'types/Matchers'; const expect = require('jest-matchers'); @@ -27,7 +26,7 @@ type JasmineMatcher = { }; type JasmineMatchersObject = {[id: string]: JasmineMatcher}; -module.exports = (config: Config) => { +module.exports = (config: {expand: boolean}) => { global.expect = expect; expect.setState({ expand: config.expand, diff --git a/packages/jest-jasmine2/src/setup-jest-globals.js b/packages/jest-jasmine2/src/setup-jest-globals.js index 512d7f655a7e..52c0351f5dc2 100644 --- a/packages/jest-jasmine2/src/setup-jest-globals.js +++ b/packages/jest-jasmine2/src/setup-jest-globals.js @@ -10,7 +10,7 @@ 'use strict'; -import type {Config, Path} from 'types/Config'; +import type {Path, ProjectConfig} from 'types/Config'; const {getState, setState} = require('jest-matchers'); const {initializeSnapshotState, addSerializer} = require('jest-snapshot'); @@ -100,7 +100,7 @@ const patchJasmine = () => { type Options = { testPath: Path, - config: Config, + config: ProjectConfig, }; module.exports = ({testPath, config}: Options) => { diff --git a/packages/jest-resolve-dependencies/src/__tests__/DependencyResolver-test.js b/packages/jest-resolve-dependencies/src/__tests__/DependencyResolver-test.js index 2df00873596c..0c3420d9e3a4 100644 --- a/packages/jest-resolve-dependencies/src/__tests__/DependencyResolver-test.js +++ b/packages/jest-resolve-dependencies/src/__tests__/DependencyResolver-test.js @@ -29,7 +29,7 @@ beforeEach(() => { config = normalizeConfig({ rootDir: '.', roots: ['./packages/jest-resolve-dependencies'], - }).config; + }).options; return Runtime.createContext(config, {maxWorkers}).then(hasteMap => { dependencyResolver = new DependencyResolver( hasteMap.resolver, diff --git a/packages/jest-runtime/src/__mocks__/createRuntime.js b/packages/jest-runtime/src/__mocks__/createRuntime.js index a3d2f328cec5..f55ffb4781b8 100644 --- a/packages/jest-runtime/src/__mocks__/createRuntime.js +++ b/packages/jest-runtime/src/__mocks__/createRuntime.js @@ -22,7 +22,7 @@ module.exports = function createRuntime(filename, config) { }, config, ), - ).config; + ).options; const environment = new NodeEnvironment(config); environment.global.console = console; diff --git a/types/Config.js b/types/Config.js index cce4b077af25..7b65acfe856a 100644 --- a/types/Config.js +++ b/types/Config.js @@ -145,66 +145,6 @@ export type DefaultConfig = {| watch: boolean, |}; -export type Config = {| - automock: boolean, - bail: boolean, - browser: boolean, - cache: boolean, - cacheDirectory: Path, - clearMocks: boolean, - collectCoverage: boolean, - collectCoverageFrom: Array, - collectCoverageOnlyFrom: {[key: string]: boolean}, - coverageDirectory: string, - coveragePathIgnorePatterns: Array, - coverageReporters: Array, - coverageThreshold: {global: {[key: string]: number}}, - expand: boolean, - forceExit: boolean, - globals: ConfigGlobals, - haste: HasteConfig, - logHeapUsage: boolean, - logTransformErrors: ?boolean, - mapCoverage: boolean, - moduleDirectories: Array, - moduleFileExtensions: Array, - moduleLoader: Path, - moduleNameMapper: {[key: string]: string} | Array<[string, string]>, - modulePathIgnorePatterns: Array, - modulePaths: Array, - name: string, - noStackTrace: boolean, - notify: boolean, - preset: ?string, - replname: ?string, - resetMocks: boolean, - resetModules: boolean, - resolver: ?Path, - rootDir: Path, - roots: Array, - setupFiles: Array, - setupTestFrameworkScriptFile: Path, - silent: boolean, - snapshotSerializers: Array, - testEnvironment: string, - testMatch: Array, - testNamePattern: string, - testPathIgnorePatterns: Array, - testRegex: string, - testResultsProcessor: ?string, - testRunner: string, - testURL: string, - timers: 'real' | 'fake', - transform: Array<[string, Path]>, - transformIgnorePatterns: Array, - unmockedModulePathPatterns: ?Array, - updateSnapshot: boolean, - useStderr: boolean, - verbose: ?boolean, - watch: boolean, - watchman: boolean, -|}; - export type InitialConfig = {| automock?: boolean, bail?: boolean, diff --git a/types/Environment.js b/types/Environment.js index 7d846832b18d..3ec4824b95e8 100644 --- a/types/Environment.js +++ b/types/Environment.js @@ -9,13 +9,13 @@ */ 'use strict'; -import type {Config} from './Config'; +import type {ProjectConfig} from './Config'; import type {Global} from './Global'; import type {Script} from 'vm'; import type {ModuleMocker} from 'jest-mock'; export type Environment = {| - constructor(config: Config): void, + constructor(config: ProjectConfig): void, dispose(): void, runScript(script: Script): any, global: Global,