Skip to content

Commit

Permalink
fix dependency issues (#11465)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed May 28, 2021
1 parent 4cae680 commit 0927834
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,7 +8,9 @@

### Fixes

- `[jest-circus]` Add missing `slash` dependency ([#11465](https://github.com/facebook/jest/pull/11465))
- `[jest-circus, @jest/test-sequencer]` Remove dependency on `jest-runner` ([#11466](https://github.com/facebook/jest/pull/11466))
- `[jest-config]` Resolve `config.runner` to absolute path ([#11465](https://github.com/facebook/jest/pull/11465))
- `[jest-core]` Do not warn about `DNSCHANNEL` handles when using the `--detectOpenHandles` option ([#11470](https://github.com/facebook/jest/pull/11470))
- `[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))
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/showConfig.test.ts.snap
Expand Up @@ -48,7 +48,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
"roots": [
"<<REPLACED_ROOT_DIR>>"
],
"runner": "jest-runner",
"runner": "<<REPLACED_JEST_PACKAGES_DIR>>/jest-runner/build/index.js",
"setupFiles": [],
"setupFilesAfterEnv": [],
"skipFilter": false,
Expand Down
1 change: 1 addition & 0 deletions packages/jest-circus/package.json
Expand Up @@ -31,6 +31,7 @@
"jest-snapshot": "^27.0.1",
"jest-util": "^27.0.1",
"pretty-format": "^27.0.1",
"slash": "^3.0.0",
"stack-utils": "^2.0.3",
"throat": "^6.0.1"
},
Expand Down
1 change: 1 addition & 0 deletions packages/jest-config/package.json
Expand Up @@ -38,6 +38,7 @@
"jest-jasmine2": "^27.0.1",
"jest-regex-util": "^27.0.1",
"jest-resolve": "^27.0.1",
"jest-runner": "^27.0.1",
"jest-util": "^27.0.1",
"jest-validate": "^27.0.1",
"micromatch": "^4.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/__tests__/normalize.test.ts
Expand Up @@ -1401,7 +1401,7 @@ describe('runner', () => {
it('defaults to `jest-runner`', async () => {
const {options} = await normalize({rootDir: '/root'}, {} as Config.Argv);

expect(options.runner).toBe('jest-runner');
expect(options.runner).toBe(require.resolve('jest-runner'));
});

it('resolves to runners that do not have the prefix', async () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/jest-config/src/normalize.ts
Expand Up @@ -1058,6 +1058,10 @@ export default async function normalize(
rootDir: options.rootDir,
});

if (newOptions.runner === DEFAULT_CONFIG.runner) {
newOptions.runner = require.resolve(newOptions.runner);
}

newOptions.nonFlagArgs = argv._?.map(arg => `${arg}`);
newOptions.testPathPattern = buildTestPathPattern(argv);
newOptions.json = !!argv.json;
Expand Down
1 change: 1 addition & 0 deletions packages/jest-config/tsconfig.json
Expand Up @@ -13,6 +13,7 @@
{"path": "../jest-get-type"},
{"path": "../jest-regex-util"},
{"path": "../jest-resolve"},
{"path": "../jest-runner"},
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../jest-validate"},
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-core/src/__tests__/runJest.test.js
Expand Up @@ -21,7 +21,10 @@ describe('runJest', () => {
await runJest({
changedFilesPromise: Promise.resolve({repos: {git: {size: 0}}}),
contexts: [],
globalConfig: {testSequencer: '@jest/test-sequencer', watch: true},
globalConfig: {
testSequencer: require.resolve('@jest/test-sequencer'),
watch: true,
},
onComplete: () => null,
outputStream: {},
startRun: {},
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-runner/src/runTest.ts
Expand Up @@ -109,7 +109,9 @@ async function runTestInternal(
await transformer.requireAndTranspileModule(testEnvironment);
const testFramework: TestFramework =
await transformer.requireAndTranspileModule(
process.env.JEST_JASMINE === '1' ? 'jest-jasmine2' : config.testRunner,
process.env.JEST_JASMINE === '1'
? require.resolve('jest-jasmine2')
: config.testRunner,
);
const Runtime: typeof RuntimeClass = interopRequireDefault(
config.moduleLoader
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-types/src/Config.ts
Expand Up @@ -98,7 +98,7 @@ export type DefaultOptions = {
restoreMocks: boolean;
roots: Array<Path>;
runTestsByPath: boolean;
runner: 'jest-runner';
runner: string;
setupFiles: Array<Path>;
setupFilesAfterEnv: Array<Path>;
skipFilter: boolean;
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-util/src/requireOrImportModule.ts
Expand Up @@ -15,7 +15,9 @@ export default async function requireOrImportModule<T>(
applyInteropRequireDefault = true,
): Promise<T> {
if (!isAbsolute(filePath) && filePath[0] === '.') {
throw new Error(`Jest: requireOrImportModule path must be absolute`);
throw new Error(
`Jest: requireOrImportModule path must be absolute, was "${filePath}"`,
);
}
try {
const requiredModule = require(filePath);
Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Expand Up @@ -13266,6 +13266,7 @@ fsevents@^1.2.7:
jest-snapshot-serializer-raw: ^1.1.0
jest-util: ^27.0.1
pretty-format: ^27.0.1
slash: ^3.0.0
stack-utils: ^2.0.3
throat: ^6.0.1
languageName: unknown
Expand Down Expand Up @@ -13327,6 +13328,7 @@ fsevents@^1.2.7:
jest-jasmine2: ^27.0.1
jest-regex-util: ^27.0.1
jest-resolve: ^27.0.1
jest-runner: ^27.0.1
jest-snapshot-serializer-raw: ^1.1.0
jest-util: ^27.0.1
jest-validate: ^27.0.1
Expand Down

0 comments on commit 0927834

Please sign in to comment.