Skip to content

Commit

Permalink
chore: remove jest-config dependency from jest-runner (#11466)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored May 28, 2021
1 parent ae3fc94 commit 5f4dd18
Show file tree
Hide file tree
Showing 49 changed files with 788 additions and 727 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-jasmine2/src/jasmine/jasmineLight.ts',
'packages/jest-jasmine2/src/jestExpect.ts',
'packages/jest-resolve/src/index.ts',
'packages/jest-resolve/src/resolver.ts',
],
rules: {
'local/prefer-spread-eventually': 'warn',
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
### Features

- `[jest-reporters]` Expose the `getResultHeader` util ([#11460](https://github.com/facebook/jest/pull/11460))
- `[jest-resolver]` Export `resolve*` utils for different Jest modules ([#11466](https://github.com/facebook/jest/pull/11466))
- `[@jest/test-result]` Export `Test`, `TestEvents` and `TestFileEvent` ([#11466](https://github.com/facebook/jest/pull/11466))

### Fixes

- `[jest-circus, @jest/test-sequencer]` Remove dependency on `jest-runner` ([#11466](https://github.com/facebook/jest/pull/11466))
- `[jest-runner]` Remove dependency on `jest-config` ([#11466](https://github.com/facebook/jest/pull/11466))
- `[jest-worker]` Loosen engine requirement to `>= 10.13.0` ([#11451](https://github.com/facebook/jest/pull/11451))

### Chore & Maintenance
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ FAIL __tests__/index.js
12 | module.exports = () => 'test';
13 |
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:558:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/resolver.js:558:17)
at Object.require (index.js:10:1)
`;

Expand Down Expand Up @@ -70,6 +70,6 @@ FAIL __tests__/index.js
12 | module.exports = () => 'test';
13 |
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:558:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/resolver.js:558:17)
at Object.require (index.js:10:1)
`;
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ FAIL __tests__/test.js
| ^
9 |
at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:311:11)
at Resolver.resolveModule (../../packages/jest-resolve/build/resolver.js:311:11)
at Object.require (index.js:8:18)
`;
2 changes: 1 addition & 1 deletion e2e/__tests__/stackTrace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('Stack Trace', () => {
);

expect(stderr).toMatch(
/\s+at\s(?:.+?)\s\((?:.+?)jest-resolve\/build\/index\.js/,
/\s+at\s(?:.+?)\s\((?:.+?)jest-resolve\/build\/resolver\.js/,
);
});

Expand Down
3 changes: 2 additions & 1 deletion e2e/async-regenerator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"testEnvironment": "node",
"transformIgnorePatterns": [
"jest-circus",
"jest-jasmine2"
"jest-jasmine2",
"jest-runner"
]
}
}
3 changes: 2 additions & 1 deletion e2e/babel-plugin-jest-hoist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"transformIgnorePatterns": [
"jest-circus",
"jest-environment-node",
"jest-jasmine2"
"jest-jasmine2",
"jest-runner"
]
}
}
5 changes: 3 additions & 2 deletions e2e/coverage-transform-instrumented/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"transformIgnorePatterns": [
"jest-circus",
"jest-each",
"jest-environment-node/",
"jest-jasmine2"
"jest-environment-node",
"jest-jasmine2",
"jest-runner"
],
"moduleFileExtensions": [
"js"
Expand Down
3 changes: 2 additions & 1 deletion e2e/transform-linked-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"jest-circus",
"jest-each",
"jest-environment-node",
"jest-jasmine2"
"jest-jasmine2",
"jest-runner"
],
"transform": {
"\\.js$": "<rootDir>/preprocessor.js"
Expand Down
6 changes: 5 additions & 1 deletion e2e/transform/babel-jest-ignored/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"jest": {
"testEnvironment": "node"
"testEnvironment": "node",
"transformIgnorePatterns": [
"node_modules",
"jest-runner"
]
}
}
3 changes: 2 additions & 1 deletion e2e/transform/multiple-transformers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"transformIgnorePatterns": [
"jest-circus",
"jest-environment-node",
"jest-jasmine2"
"jest-jasmine2",
"jest-runner"
]
},
"dependencies": {
Expand Down
5 changes: 2 additions & 3 deletions e2e/transform/transform-runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
*/

import throat from 'throat';
import {TestResult, createEmptyTestResult} from '@jest/test-result';
import {Test, TestResult, createEmptyTestResult} from '@jest/test-result';
import type {Config} from '@jest/types';
import {
import type {
OnTestFailure,
OnTestStart,
OnTestSuccess,
Test,
TestRunnerContext,
TestWatcher,
} from 'jest-runner';
Expand Down
1 change: 0 additions & 1 deletion packages/jest-circus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"jest-each": "^27.0.1",
"jest-matcher-utils": "^27.0.1",
"jest-message-util": "^27.0.1",
"jest-runner": "^27.0.1",
"jest-runtime": "^27.0.1",
"jest-snapshot": "^27.0.1",
"jest-util": "^27.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
*/

import type {JestEnvironment} from '@jest/environment';
import type {TestResult} from '@jest/test-result';
import type {TestFileEvent, TestResult} from '@jest/test-result';
import type {Config} from '@jest/types';
import type {TestFileEvent} from 'jest-runner';
import type Runtime from 'jest-runtime';
import type {SnapshotStateType} from 'jest-snapshot';
import {deepCyclicCopy} from 'jest-util';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import type {JestEnvironment} from '@jest/environment';
import {
AssertionResult,
Status,
TestFileEvent,
TestResult,
createEmptyTestResult,
} from '@jest/test-result';
import type {Circus, Config, Global} from '@jest/types';
import {extractExpectedAssertionsErrors, getState, setState} from 'expect';
import {bind} from 'jest-each';
import {formatExecError, formatResultsErrors} from 'jest-message-util';
import type {TestFileEvent} from 'jest-runner';
import {
SnapshotState,
SnapshotStateType,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/testCaseReportHandler.ts
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 type {TestFileEvent} from '@jest/test-result';
import type {Circus} from '@jest/types';
import type {TestFileEvent} from 'jest-runner';
import {makeSingleTestResult, parseSingleTestResult} from './utils';

const testCaseReportHandler =
Expand Down
1 change: 0 additions & 1 deletion packages/jest-circus/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
{"path": "../jest-environment"},
{"path": "../jest-matcher-utils"},
{"path": "../jest-message-util"},
{"path": "../jest-runner"},
{"path": "../jest-runtime"},
{"path": "../jest-snapshot"},
{"path": "../jest-test-result"},
Expand Down
6 changes: 5 additions & 1 deletion packages/jest-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import normalize from './normalize';
import readConfigFileAndSetRootDir from './readConfigFileAndSetRootDir';
import resolveConfigPath from './resolveConfigPath';
import {isJSONString, replaceRootDirInPath} from './utils';
export {getTestEnvironment, isJSONString} from './utils';

// TODO: remove export in Jest 28
export {resolveTestEnvironment as getTestEnvironment} from 'jest-resolve';

export {isJSONString} from './utils';
export {default as normalize} from './normalize';
export {default as deprecationEntries} from './Deprecated';
export {replaceRootDirInPath} from './utils';
Expand Down
22 changes: 12 additions & 10 deletions packages/jest-config/src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import {statSync} from 'graceful-fs';
import micromatch = require('micromatch');
import type {Config} from '@jest/types';
import {replacePathSepForRegex} from 'jest-regex-util';
import Resolver from 'jest-resolve';
import Resolver, {
resolveRunner,
resolveSequencer,
resolveTestEnvironment,
resolveWatchPlugin,
} from 'jest-resolve';
import {
clearLine,
replacePathSepForGlob,
Expand All @@ -35,14 +40,11 @@ import {
DOCUMENTATION_NOTE,
_replaceRootDirTags,
escapeGlobCharacters,
getRunner,
getSequencer,
getTestEnvironment,
getWatchPlugin,
replaceRootDirInPath,
resolve,
} from './utils';
import validatePattern from './validatePattern';

const ERROR = `${BULLET}Validation Error`;
const PRESET_EXTENSIONS = ['.json', '.js', '.cjs', '.mjs'];
const PRESET_NAME = 'jest-preset';
Expand Down Expand Up @@ -604,7 +606,7 @@ export default async function normalize(
options.setupFilesAfterEnv.push(options.setupTestFrameworkScriptFile);
}

options.testEnvironment = getTestEnvironment({
options.testEnvironment = resolveTestEnvironment({
rootDir: options.rootDir,
testEnvironment: options.testEnvironment || DEFAULT_CONFIG.testEnvironment,
});
Expand Down Expand Up @@ -739,7 +741,7 @@ export default async function normalize(
const option = oldOptions[key];
value =
option &&
getRunner(newOptions.resolver, {
resolveRunner(newOptions.resolver, {
filePath: option,
rootDir: options.rootDir,
});
Expand Down Expand Up @@ -1010,15 +1012,15 @@ export default async function normalize(
if (typeof watchPlugin === 'string') {
return {
config: {},
path: getWatchPlugin(newOptions.resolver, {
path: resolveWatchPlugin(newOptions.resolver, {
filePath: watchPlugin,
rootDir: options.rootDir,
}),
};
} else {
return {
config: watchPlugin[1] || {},
path: getWatchPlugin(newOptions.resolver, {
path: resolveWatchPlugin(newOptions.resolver, {
filePath: watchPlugin[0],
rootDir: options.rootDir,
}),
Expand Down Expand Up @@ -1051,7 +1053,7 @@ export default async function normalize(
// ignored
}

newOptions.testSequencer = getSequencer(newOptions.resolver, {
newOptions.testSequencer = resolveSequencer(newOptions.resolver, {
filePath: options.testSequencer || DEFAULT_CONFIG.testSequencer,
rootDir: options.rootDir,
});
Expand Down
Loading

0 comments on commit 5f4dd18

Please sign in to comment.