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

fix(jest-cli): use import-local to support global Jest installations #5304

Merged
merged 2 commits into from
Jan 14, 2018
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
20 changes: 14 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
## master

### Fixes

* `[jest-cli]` Use `import-local` to support global Jest installations.
([#5304](https://github.com/facebook/jest/pull/5304))

## jest 22.0.7

### Fixes

* `[jest-runner]` Fix memory leak in coverage reporting ([#5289](https://github.com/facebook/jest/pull/5289))
* `[jest-runner]` Fix memory leak in coverage reporting
([#5289](https://github.com/facebook/jest/pull/5289))

### Features

* `[jest-cli]` Make Jest exit without an error when no tests are found in
the case of `--lastCommit`, `--findRelatedTests`, or `--onlyChanged` options
* `[jest-cli]` Make Jest exit without an error when no tests are found in the
case of `--lastCommit`, `--findRelatedTests`, or `--onlyChanged` options
having been passed to the CLI

## jest 22.0.6

### Fixes

* `[jest-jasmine2]` Fix memory leak in snapshot reporting ([#5279](https://github.com/facebook/jest/pull/5279))
* `[jest-config]` Fix breaking change in `--testPathPattern` ([#5269](https://github.com/facebook/jest/pull/5269))
* `[jest-jasmine2]` Fix memory leak in snapshot reporting
([#5279](https://github.com/facebook/jest/pull/5279))
* `[jest-config]` Fix breaking change in `--testPathPattern`
([#5269](https://github.com/facebook/jest/pull/5269))

### Fixes

* `[docs]` Document caveat with mocks, Enzyme, snapshots and React 16
([#5258](https://github.com/facebook/jest/issues/5258))
([#5258](https://github.com/facebook/jest/issues/5258))

## jest 22.0.5

Expand Down
12 changes: 8 additions & 4 deletions packages/jest-cli/bin/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
* LICENSE file in the root directory of this source tree.
*/

if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'test';
}
const importLocal = require('import-local');

if (!importLocal(__filename)) {
if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'test';
}

require('../build/cli').run();
require('../build/cli').run();
}
1 change: 1 addition & 0 deletions packages/jest-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"chalk": "^2.0.1",
"glob": "^7.1.2",
"graceful-fs": "^4.1.11",
"import-local": "^1.0.0",
"is-ci": "^1.0.10",
"istanbul-api": "^1.1.14",
"istanbul-lib-coverage": "^1.1.1",
Expand Down
47 changes: 0 additions & 47 deletions packages/jest-cli/src/cli/get_jest.js

This file was deleted.

9 changes: 1 addition & 8 deletions packages/jest-cli/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import * as args from './args';
import chalk from 'chalk';
import createContext from '../lib/create_context';
import getChangedFilesPromise from '../get_changed_files_promise';
import getJest from './get_jest';
import handleDeprecationWarnings from '../lib/handle_deprecation_warnings';
import logDebugMessages from '../lib/log_debug_messages';
import {print as preRunMessagePrint} from '../pre_run_message';
Expand All @@ -39,11 +38,8 @@ export async function run(maybeArgv?: Argv, project?: Path) {
try {
const argv: Argv = buildArgv(maybeArgv, project);
const projects = getProjectListFromCLIArgs(argv, project);
// If we're running a single Jest project, we might want to use another
// version of Jest (the one that is specified in this project's package.json)
const runCLIFn = getRunCLIFn(projects);

const {results, globalConfig} = await runCLIFn(argv, projects);
const {results, globalConfig} = await runCLI(argv, projects);
readResultsAndExit(results, globalConfig);
} catch (error) {
clearLine(process.stderr);
Expand Down Expand Up @@ -158,9 +154,6 @@ const getProjectListFromCLIArgs = (argv, project: ?Path) => {
return projects;
};

const getRunCLIFn = (projects: Array<Path>) =>
projects.length === 1 ? getJest(projects[0]).runCLI : runCLI;

const printDebugInfoAndExitIfNeeded = (
argv,
globalConfig,
Expand Down
23 changes: 23 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4021,6 +4021,13 @@ immutable@^4.0.0-rc.7:
version "4.0.0-rc.9"
resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0-rc.9.tgz#1e6e0094e649013ec3742d2b5aeeca5eeda4f0bf"

import-local@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/import-local/-/import-local-1.0.0.tgz#5e4ffdc03f4fe6c009c6729beb29631c2f8227bc"
dependencies:
pkg-dir "^2.0.0"
resolve-cwd "^2.0.0"

import-modules@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/import-modules/-/import-modules-1.1.0.tgz#748db79c5cc42bb9701efab424f894e72600e9dc"
Expand Down Expand Up @@ -6131,6 +6138,12 @@ pkg-dir@^1.0.0:
dependencies:
find-up "^1.0.0"

pkg-dir@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b"
dependencies:
find-up "^2.1.0"

[email protected]:
version "2.0.1"
resolved "https://registry.yarnpkg.com/plist/-/plist-2.0.1.tgz#0a32ca9481b1c364e92e18dc55c876de9d01da8b"
Expand Down Expand Up @@ -6872,10 +6885,20 @@ [email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"

resolve-cwd@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
dependencies:
resolve-from "^3.0.0"

resolve-from@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"

resolve-from@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748"

[email protected]:
version "1.1.7"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
Expand Down