Skip to content

Commit bc23f43

Browse files
authored
chore: move TestUtils file into test utils package (#10756)
1 parent f9132f9 commit bc23f43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+68
-34
lines changed

packages/babel-jest/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"devDependencies": {
2424
"@babel/core": "^7.1.0",
25+
"@jest/test-utils": "^26.5.0",
2526
"@types/graceful-fs": "^4.1.3"
2627
},
2728
"peerDependencies": {

packages/babel-jest/src/__tests__/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {makeProjectConfig} from '../../../../TestUtils';
8+
import {makeProjectConfig} from '@jest/test-utils';
99
import babelJest = require('../index');
1010
import {loadPartialConfig} from '../loadBabelConfig';
1111

packages/babel-jest/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// TODO: include `babel-preset-jest` if it's ever in TS even though we don't care about its types
88
"references": [
99
{"path": "../jest-transform"},
10-
{"path": "../jest-types"}
10+
{"path": "../jest-types"},
11+
{"path": "../test-utils"}
1112
]
1213
}

packages/jest-config/src/__tests__/resolveConfigPath.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import {tmpdir} from 'os';
99
import * as path from 'path';
10+
import {cleanup, writeFiles} from '../../../../e2e/Utils';
1011
import {JEST_CONFIG_EXT_ORDER} from '../constants';
1112
import resolveConfigPath from '../resolveConfigPath';
12-
const {cleanup, writeFiles} = require('../../../../e2e/Utils');
1313

1414
const DIR = path.resolve(tmpdir(), 'resolve_config_path_test');
1515
const ERROR_PATTERN = /Could not find a config file based on provided values/;

packages/jest-console/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"slash": "^3.0.0"
1919
},
2020
"devDependencies": {
21+
"@jest/test-utils": "^26.5.0",
2122
"@types/node": "*"
2223
},
2324
"engines": {

packages/jest-console/src/__tests__/getConsoleOutput.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
import {makeGlobalConfig} from '@jest/test-utils';
89
import {formatStackTrace} from 'jest-message-util';
9-
import {makeGlobalConfig} from '../../../../TestUtils';
1010
import BufferedConsole from '../BufferedConsole';
1111
import getConsoleOutput from '../getConsoleOutput';
1212
import type {LogType} from '../types';

packages/jest-console/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"references": [
88
{"path": "../jest-message-util"},
99
{"path": "../jest-types"},
10-
{"path": "../jest-util"}
10+
{"path": "../jest-util"},
11+
{"path": "../test-utils"}
1112
]
1213
}

packages/jest-core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
},
3737
"devDependencies": {
3838
"@jest/test-sequencer": "^26.6.1",
39+
"@jest/test-utils": "^26.5.0",
3940
"@types/exit": "^0.1.30",
4041
"@types/graceful-fs": "^4.1.2",
4142
"@types/micromatch": "^4.0.0",

packages/jest-core/src/__tests__/TestScheduler.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {SummaryReporter} from '@jest/reporters';
10-
import {makeProjectConfig} from '../../../../TestUtils';
10+
import {makeProjectConfig} from '@jest/test-utils';
1111
import TestScheduler from '../TestScheduler';
1212
import * as testSchedulerHelper from '../testSchedulerHelper';
1313

packages/jest-core/src/__tests__/watchFileChanges.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ describe('Watch mode flows with changed files', () => {
3131
const cacheDirectory = path.resolve(tmpdir(), `tmp${Math.random()}`);
3232
let hasteMapInstance: HasteMap;
3333

34-
beforeEach(() => {
35-
watch = require('../watch').default;
34+
beforeEach(async () => {
35+
watch = (await import('../watch')).default;
3636
pipe = {write: jest.fn()} as unknown;
3737
stdin = new MockStdin();
3838
rimraf.sync(cacheDirectory);

packages/jest-core/src/lib/__tests__/isValidPath.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import * as path from 'path';
9-
import {makeGlobalConfig} from '../../../../../TestUtils';
9+
import {makeGlobalConfig} from '@jest/test-utils';
1010
import isValidPath from '../isValidPath';
1111

1212
const rootDir = path.resolve(path.sep, 'root');

packages/jest-core/src/lib/__tests__/logDebugMessages.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {wrap} from 'jest-snapshot-serializer-raw';
10-
import {makeGlobalConfig, makeProjectConfig} from '../../../../../TestUtils';
10+
import {makeGlobalConfig, makeProjectConfig} from '@jest/test-utils';
1111
import logDebugMessages from '../logDebugMessages';
1212

1313
jest.mock('../../../package.json', () => ({version: 123}));

packages/jest-core/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
{"path": "../jest-transform"},
2323
{"path": "../jest-util"},
2424
{"path": "../jest-validate"},
25-
{"path": "../jest-watcher"}
25+
{"path": "../jest-watcher"},
26+
{"path": "../test-utils"}
2627
]
2728
}

packages/jest-create-cache-key-function/src/__tests__/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ afterEach(() => {
2020
process.env.BABEL_ENV = BABEL_ENV;
2121
});
2222

23-
test('creation of a cache key', () => {
24-
const createCacheKeyFunction = require('../index').default;
23+
test('creation of a cache key', async () => {
24+
const createCacheKeyFunction = (await import('../index')).default;
2525
const createCacheKey = createCacheKeyFunction([], ['value']);
2626
const hashA = createCacheKey('test', 'test.js', null, {
2727
config: {},

packages/jest-environment-jsdom/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"jsdom": "^16.4.0"
2020
},
2121
"devDependencies": {
22+
"@jest/test-utils": "^26.5.0",
2223
"@types/jsdom": "^16.2.4"
2324
},
2425
"engines": {

packages/jest-environment-jsdom/src/__tests__/jsdom_environment.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
import {makeProjectConfig} from '@jest/test-utils';
89
import JSDomEnvironment = require('../');
9-
import {makeProjectConfig} from '../../../../TestUtils';
1010

1111
describe('JSDomEnvironment', () => {
1212
it('should configure setTimeout/setInterval to use the browser api', () => {

packages/jest-environment-jsdom/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{"path": "../jest-fake-timers"},
1010
{"path": "../jest-mock"},
1111
{"path": "../jest-types"},
12-
{"path": "../jest-util"}
12+
{"path": "../jest-util"},
13+
{"path": "../test-utils"}
1314
]
1415
}

packages/jest-environment-node/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"jest-mock": "^26.6.1",
1818
"jest-util": "^26.6.1"
1919
},
20+
"devDependencies": {
21+
"@jest/test-utils": "^26.5.0"
22+
},
2023
"engines": {
2124
"node": ">= 10.14.2"
2225
},

packages/jest-environment-node/src/__tests__/node_environment.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
import {makeProjectConfig} from '@jest/test-utils';
89
import NodeEnvironment = require('../');
9-
import {makeProjectConfig} from '../../../../TestUtils';
1010

1111
const isTextEncoderDefined = typeof TextEncoder === 'function';
1212

packages/jest-environment-node/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{"path": "../jest-fake-timers"},
1010
{"path": "../jest-mock"},
1111
{"path": "../jest-types"},
12-
{"path": "../jest-util"}
12+
{"path": "../jest-util"},
13+
{"path": "../test-utils"}
1314
]
1415
}

packages/jest-reporters/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"v8-to-istanbul": "^7.0.0"
3232
},
3333
"devDependencies": {
34+
"@jest/test-utils": "^26.5.0",
3435
"@types/exit": "^0.1.30",
3536
"@types/glob": "^7.1.1",
3637
"@types/graceful-fs": "^4.1.3",

packages/jest-reporters/src/__tests__/NotifyReporter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
*/
77

88
import type {AggregatedResult} from '@jest/test-result';
9+
import {makeGlobalConfig} from '@jest/test-utils';
910
import type {Config} from '@jest/types';
1011
import Resolver from 'jest-resolve';
11-
import {makeGlobalConfig} from '../../../../TestUtils';
1212
import NotifyReporter from '../NotifyReporter';
1313

1414
jest.mock('../DefaultReporter');

packages/jest-reporters/src/__tests__/generateEmptyCoverage.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import os from 'os';
99
import path from 'path';
1010
import istanbulCoverage from 'istanbul-lib-coverage';
1111
import libSourceMaps from 'istanbul-lib-source-maps';
12+
import {makeGlobalConfig, makeProjectConfig} from '@jest/test-utils';
1213
import {shouldInstrument} from '@jest/transform';
13-
import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils';
1414
import generateEmptyCoverage from '../generateEmptyCoverage';
1515

1616
jest.mock('@jest/transform', () => ({

packages/jest-reporters/src/__tests__/getResultHeader.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {makeGlobalConfig} from '../../../../TestUtils';
8+
import {makeGlobalConfig} from '@jest/test-utils';
99
import getResultHeader from '../getResultHeader';
1010
const terminalLink = require('terminal-link');
1111

packages/jest-reporters/src/__tests__/getWatermarks.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {makeGlobalConfig} from '../../../../TestUtils';
8+
import {makeGlobalConfig} from '@jest/test-utils';
99
import getWatermarks from '../getWatermarks';
1010

1111
describe('getWatermarks', () => {

packages/jest-reporters/src/__tests__/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import * as path from 'path';
99
import chalk = require('chalk');
1010
import stripAnsi = require('strip-ansi');
11-
import {makeProjectConfig} from '../../../../TestUtils';
11+
import {makeProjectConfig} from '@jest/test-utils';
1212
import {printDisplayName, trimAndFormatPath, wrapAnsiString} from '../utils';
1313

1414
describe('wrapAnsiString()', () => {

packages/jest-reporters/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{"path": "../jest-test-result"},
1212
{"path": "../jest-types"},
1313
{"path": "../jest-util"},
14-
{"path": "../jest-worker"}
14+
{"path": "../jest-worker"},
15+
{"path": "../test-utils"}
1516
]
1617
}

packages/jest-resolve-dependencies/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"jest-snapshot": "^26.6.1"
1616
},
1717
"devDependencies": {
18+
"@jest/test-utils": "^26.5.0",
1819
"jest-haste-map": "^26.6.1",
1920
"jest-resolve": "^26.6.1",
2021
"jest-runtime": "^26.6.1"

packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
import {tmpdir} from 'os';
99
import * as path from 'path';
10+
import {makeProjectConfig} from '@jest/test-utils';
1011
import type {Config} from '@jest/types';
1112
import Resolver = require('jest-resolve');
1213
import {buildSnapshotResolver} from 'jest-snapshot';
13-
import {makeProjectConfig} from '../../../../TestUtils';
1414
import DependencyResolver from '../index';
1515

1616
const maxWorkers = 1;

packages/jest-resolve-dependencies/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"references": [
88
{"path": "../jest-regex-util"},
99
{"path": "../jest-snapshot"},
10-
{"path": "../jest-types"}
10+
{"path": "../jest-types"},
11+
{"path": "../test-utils"}
1112
]
1213
}

packages/jest-runtime/src/__tests__/instrumentation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
import * as os from 'os';
1010
import * as path from 'path';
11+
import {makeGlobalConfig, makeProjectConfig} from '@jest/test-utils';
1112
import {ScriptTransformer} from '@jest/transform';
12-
import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils';
1313

1414
jest.mock('vm');
1515

packages/jest-runtime/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
{"path": "../jest-types"},
2424
{"path": "../jest-util"},
2525
{"path": "../jest-validate"},
26-
{"path": "../pretty-format"}
26+
{"path": "../pretty-format"},
27+
{"path": "../test-utils"}
2728
]
2829
}

packages/jest-snapshot/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
},
3030
"devDependencies": {
3131
"@babel/traverse": "^7.3.4",
32+
"@jest/test-utils": "^26.5.0",
3233
"@types/graceful-fs": "^4.1.3",
3334
"@types/natural-compare": "^1.4.0",
3435
"@types/semver": "^7.1.0",

packages/jest-snapshot/src/__tests__/SnapshotResolver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import * as path from 'path';
9-
import {makeProjectConfig} from '../../../../TestUtils';
9+
import {makeProjectConfig} from '@jest/test-utils';
1010
import {SnapshotResolver, buildSnapshotResolver} from '../SnapshotResolver';
1111

1212
describe('defaults', () => {

packages/jest-snapshot/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
{"path": "../jest-message-util"},
1414
{"path": "../jest-resolve"},
1515
{"path": "../jest-types"},
16-
{"path": "../pretty-format"}
16+
{"path": "../pretty-format"},
17+
{"path": "../test-utils"}
1718
]
1819
}

packages/jest-transform/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"write-file-atomic": "^3.0.0"
2828
},
2929
"devDependencies": {
30+
"@jest/test-utils": "^26.5.0",
3031
"@types/babel__core": "^7.1.0",
3132
"@types/convert-source-map": "^1.5.1",
3233
"@types/fast-json-stable-stringify": "^2.0.0",

packages/jest-transform/src/__tests__/script_transformer.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {wrap} from 'jest-snapshot-serializer-raw';
10-
import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils';
10+
import {makeGlobalConfig, makeProjectConfig} from '@jest/test-utils';
1111

1212
jest
1313
.mock('graceful-fs', () =>

packages/jest-transform/src/__tests__/should_instrument.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
import {makeGlobalConfig, makeProjectConfig} from '@jest/test-utils';
89
import type {Config} from '@jest/types';
9-
import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils';
1010
import shouldInstrument from '../shouldInstrument';
11-
import {Options} from '../types';
11+
import type {Options} from '../types';
1212

1313
describe('shouldInstrument', () => {
1414
const defaultFilename = 'source_file.test.js';

packages/jest-transform/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
{"path": "../jest-haste-map"},
99
{"path": "../jest-regex-util"},
1010
{"path": "../jest-types"},
11-
{"path": "../jest-util"}
11+
{"path": "../jest-util"},
12+
{"path": "../test-utils"}
1213
]
1314
}

packages/test-utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"dependencies": {
9+
"@jest/types": "^26.6.1",
910
"@types/jest": "*",
1011
"@types/node": "*",
1112
"@types/semver": "^7.1.0",
File renamed without changes.

packages/test-utils/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ export {
1313
skipSuiteOnJestCircus,
1414
onNodeVersions,
1515
} from './ConditionalTest';
16+
17+
export {makeGlobalConfig, makeProjectConfig} from './config';

packages/test-utils/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"rootDir": "src",
55
"outDir": "build"
66
},
7-
"references": [{"path": "../jest-types"}]
7+
"references": [{"path": "../jest-types"}, {"path": "../pretty-format"}]
88
}

0 commit comments

Comments
 (0)