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

chore: move TestUtils file into test utils package #10756

Merged
merged 1 commit into from
Oct 31, 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
1 change: 1 addition & 0 deletions packages/babel-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@jest/test-utils": "^26.5.0",
"@types/graceful-fs": "^4.1.3"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-jest/src/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

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

Expand Down
3 changes: 2 additions & 1 deletion packages/babel-jest/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// TODO: include `babel-preset-jest` if it's ever in TS even though we don't care about its types
"references": [
{"path": "../jest-transform"},
{"path": "../jest-types"}
{"path": "../jest-types"},
{"path": "../test-utils"}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import {tmpdir} from 'os';
import * as path from 'path';
import {cleanup, writeFiles} from '../../../../e2e/Utils';
import {JEST_CONFIG_EXT_ORDER} from '../constants';
import resolveConfigPath from '../resolveConfigPath';
const {cleanup, writeFiles} = require('../../../../e2e/Utils');

const DIR = path.resolve(tmpdir(), 'resolve_config_path_test');
const ERROR_PATTERN = /Could not find a config file based on provided values/;
Expand Down
1 change: 1 addition & 0 deletions packages/jest-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"slash": "^3.0.0"
},
"devDependencies": {
"@jest/test-utils": "^26.5.0",
"@types/node": "*"
},
"engines": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import {makeGlobalConfig} from '@jest/test-utils';
import {formatStackTrace} from 'jest-message-util';
import {makeGlobalConfig} from '../../../../TestUtils';
import BufferedConsole from '../BufferedConsole';
import getConsoleOutput from '../getConsoleOutput';
import type {LogType} from '../types';
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-console/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"references": [
{"path": "../jest-message-util"},
{"path": "../jest-types"},
{"path": "../jest-util"}
{"path": "../jest-util"},
{"path": "../test-utils"}
]
}
1 change: 1 addition & 0 deletions packages/jest-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"devDependencies": {
"@jest/test-sequencer": "^26.6.1",
"@jest/test-utils": "^26.5.0",
"@types/exit": "^0.1.30",
"@types/graceful-fs": "^4.1.2",
"@types/micromatch": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/__tests__/TestScheduler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {SummaryReporter} from '@jest/reporters';
import {makeProjectConfig} from '../../../../TestUtils';
import {makeProjectConfig} from '@jest/test-utils';
import TestScheduler from '../TestScheduler';
import * as testSchedulerHelper from '../testSchedulerHelper';

Expand Down
4 changes: 2 additions & 2 deletions packages/jest-core/src/__tests__/watchFileChanges.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('Watch mode flows with changed files', () => {
const cacheDirectory = path.resolve(tmpdir(), `tmp${Math.random()}`);
let hasteMapInstance: HasteMap;

beforeEach(() => {
watch = require('../watch').default;
beforeEach(async () => {
watch = (await import('../watch')).default;
pipe = {write: jest.fn()} as unknown;
stdin = new MockStdin();
rimraf.sync(cacheDirectory);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/lib/__tests__/isValidPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as path from 'path';
import {makeGlobalConfig} from '../../../../../TestUtils';
import {makeGlobalConfig} from '@jest/test-utils';
import isValidPath from '../isValidPath';

const rootDir = path.resolve(path.sep, 'root');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

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

jest.mock('../../../package.json', () => ({version: 123}));
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{"path": "../jest-transform"},
{"path": "../jest-util"},
{"path": "../jest-validate"},
{"path": "../jest-watcher"}
{"path": "../jest-watcher"},
{"path": "../test-utils"}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ afterEach(() => {
process.env.BABEL_ENV = BABEL_ENV;
});

test('creation of a cache key', () => {
const createCacheKeyFunction = require('../index').default;
test('creation of a cache key', async () => {
const createCacheKeyFunction = (await import('../index')).default;
const createCacheKey = createCacheKeyFunction([], ['value']);
const hashA = createCacheKey('test', 'test.js', null, {
config: {},
Expand Down
1 change: 1 addition & 0 deletions packages/jest-environment-jsdom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"jsdom": "^16.4.0"
},
"devDependencies": {
"@jest/test-utils": "^26.5.0",
"@types/jsdom": "^16.2.4"
},
"engines": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

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

describe('JSDomEnvironment', () => {
it('should configure setTimeout/setInterval to use the browser api', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-environment-jsdom/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{"path": "../jest-fake-timers"},
{"path": "../jest-mock"},
{"path": "../jest-types"},
{"path": "../jest-util"}
{"path": "../jest-util"},
{"path": "../test-utils"}
]
}
3 changes: 3 additions & 0 deletions packages/jest-environment-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"jest-mock": "^26.6.1",
"jest-util": "^26.6.1"
},
"devDependencies": {
"@jest/test-utils": "^26.5.0"
},
"engines": {
"node": ">= 10.14.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

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

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

Expand Down
3 changes: 2 additions & 1 deletion packages/jest-environment-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{"path": "../jest-fake-timers"},
{"path": "../jest-mock"},
{"path": "../jest-types"},
{"path": "../jest-util"}
{"path": "../jest-util"},
{"path": "../test-utils"}
]
}
1 change: 1 addition & 0 deletions packages/jest-reporters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"v8-to-istanbul": "^7.0.0"
},
"devDependencies": {
"@jest/test-utils": "^26.5.0",
"@types/exit": "^0.1.30",
"@types/glob": "^7.1.1",
"@types/graceful-fs": "^4.1.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import type {AggregatedResult} from '@jest/test-result';
import {makeGlobalConfig} from '@jest/test-utils';
import type {Config} from '@jest/types';
import Resolver from 'jest-resolve';
import {makeGlobalConfig} from '../../../../TestUtils';
import NotifyReporter from '../NotifyReporter';

jest.mock('../DefaultReporter');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import os from 'os';
import path from 'path';
import istanbulCoverage from 'istanbul-lib-coverage';
import libSourceMaps from 'istanbul-lib-source-maps';
import {makeGlobalConfig, makeProjectConfig} from '@jest/test-utils';
import {shouldInstrument} from '@jest/transform';
import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils';
import generateEmptyCoverage from '../generateEmptyCoverage';

jest.mock('@jest/transform', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

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

describe('getWatermarks', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-reporters/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import * as path from 'path';
import chalk = require('chalk');
import stripAnsi = require('strip-ansi');
import {makeProjectConfig} from '../../../../TestUtils';
import {makeProjectConfig} from '@jest/test-utils';
import {printDisplayName, trimAndFormatPath, wrapAnsiString} from '../utils';

describe('wrapAnsiString()', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-reporters/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{"path": "../jest-test-result"},
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../jest-worker"}
{"path": "../jest-worker"},
{"path": "../test-utils"}
]
}
1 change: 1 addition & 0 deletions packages/jest-resolve-dependencies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"jest-snapshot": "^26.6.1"
},
"devDependencies": {
"@jest/test-utils": "^26.5.0",
"jest-haste-map": "^26.6.1",
"jest-resolve": "^26.6.1",
"jest-runtime": "^26.6.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import {tmpdir} from 'os';
import * as path from 'path';
import {makeProjectConfig} from '@jest/test-utils';
import type {Config} from '@jest/types';
import Resolver = require('jest-resolve');
import {buildSnapshotResolver} from 'jest-snapshot';
import {makeProjectConfig} from '../../../../TestUtils';
import DependencyResolver from '../index';

const maxWorkers = 1;
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-resolve-dependencies/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"references": [
{"path": "../jest-regex-util"},
{"path": "../jest-snapshot"},
{"path": "../jest-types"}
{"path": "../jest-types"},
{"path": "../test-utils"}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import * as os from 'os';
import * as path from 'path';
import {makeGlobalConfig, makeProjectConfig} from '@jest/test-utils';
import {ScriptTransformer} from '@jest/transform';
import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils';

jest.mock('vm');

Expand Down
3 changes: 2 additions & 1 deletion packages/jest-runtime/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../jest-validate"},
{"path": "../pretty-format"}
{"path": "../pretty-format"},
{"path": "../test-utils"}
]
}
1 change: 1 addition & 0 deletions packages/jest-snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"devDependencies": {
"@babel/traverse": "^7.3.4",
"@jest/test-utils": "^26.5.0",
"@types/graceful-fs": "^4.1.3",
"@types/natural-compare": "^1.4.0",
"@types/semver": "^7.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

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

describe('defaults', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-snapshot/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{"path": "../jest-message-util"},
{"path": "../jest-resolve"},
{"path": "../jest-types"},
{"path": "../pretty-format"}
{"path": "../pretty-format"},
{"path": "../test-utils"}
]
}
1 change: 1 addition & 0 deletions packages/jest-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"write-file-atomic": "^3.0.0"
},
"devDependencies": {
"@jest/test-utils": "^26.5.0",
"@types/babel__core": "^7.1.0",
"@types/convert-source-map": "^1.5.1",
"@types/fast-json-stable-stringify": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

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

jest
.mock('graceful-fs', () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/

import {makeGlobalConfig, makeProjectConfig} from '@jest/test-utils';
import type {Config} from '@jest/types';
import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils';
import shouldInstrument from '../shouldInstrument';
import {Options} from '../types';
import type {Options} from '../types';

describe('shouldInstrument', () => {
const defaultFilename = 'source_file.test.js';
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-transform/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{"path": "../jest-haste-map"},
{"path": "../jest-regex-util"},
{"path": "../jest-types"},
{"path": "../jest-util"}
{"path": "../jest-util"},
{"path": "../test-utils"}
]
}
1 change: 1 addition & 0 deletions packages/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@jest/types": "^26.6.1",
"@types/jest": "*",
"@types/node": "*",
"@types/semver": "^7.1.0",
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions packages/test-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ export {
skipSuiteOnJestCircus,
onNodeVersions,
} from './ConditionalTest';

export {makeGlobalConfig, makeProjectConfig} from './config';
2 changes: 1 addition & 1 deletion packages/test-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"rootDir": "src",
"outDir": "build"
},
"references": [{"path": "../jest-types"}]
"references": [{"path": "../jest-types"}, {"path": "../pretty-format"}]
}
Loading