diff --git a/CHANGELOG.md b/CHANGELOG.md index 6689292c5053..2340989f8d57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - `[jest-haste-map]` [**BREAKING**] Remove name from hash in `HasteMap.getCacheFilePath` ([#7218](https://github.com/facebook/jest/pull/7218)) - `[babel-preset-jest]` [**BREAKING**] Export a function instead of an object for Babel 7 compatibility ([#7203](https://github.com/facebook/jest/pull/7203)) - `[jest-haste-map]` [**BREAKING**] Expose relative paths when getting the file iterator ([#7321](https://github.com/facebook/jest/pull/7321)) +- `[jest-cli]` Print version ending in `-dev` when running a local Jest clone - `[jest-cli]` Add Support for `globalSetup` and `globalTeardown` in projects ([#6865](https://github.com/facebook/jest/pull/6865)) - `[jest-runtime]` Add `extraGlobals` to config to load extra global variables into the execution vm ([#7454](https://github.com/facebook/jest/pull/7454)) - `[jest-util]` Export `specialChars` containing Unicode characters and ANSI escapes for console output ([#7532](https://github.com/facebook/jest/pull/7532)) diff --git a/e2e/__tests__/version.test.js b/e2e/__tests__/version.test.js index f0ba2751582c..6e601a207aed 100644 --- a/e2e/__tests__/version.test.js +++ b/e2e/__tests__/version.test.js @@ -26,7 +26,7 @@ test('works with jest.config.js', () => { }); const {status, stdout, stderr} = runJest(DIR, ['--version']); - expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*$/); + expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/); // Only version gets printed and nothing else expect(stdout.split(/\n/)).toHaveLength(1); expect(stderr).toBe(''); diff --git a/packages/jest-cli/src/cli/index.js b/packages/jest-cli/src/cli/index.js index 65de1406434e..f639cfb7ca92 100644 --- a/packages/jest-cli/src/cli/index.js +++ b/packages/jest-cli/src/cli/index.js @@ -11,6 +11,7 @@ import type {AggregatedResult} from 'types/TestResult'; import type {Argv} from 'types/Argv'; import type {GlobalConfig, Path} from 'types/Config'; +import path from 'path'; import {Console, clearLine, createDirectory} from 'jest-util'; import {validateCLIOptions} from 'jest-validate'; import {readConfigs, deprecationEntries} from 'jest-config'; @@ -22,6 +23,7 @@ import getChangedFilesPromise from '../getChangedFilesPromise'; import {formatHandleErrors} from '../collectHandles'; import handleDeprecationWarnings from '../lib/handle_deprecation_warnings'; import {print as preRunMessagePrint} from '../preRunMessage'; +import {getVersion} from '../jest'; import runJest from '../runJest'; import Runtime from 'jest-runtime'; import TestWatcher from '../TestWatcher'; @@ -176,9 +178,14 @@ const readResultsAndExit = ( }; export const buildArgv = (maybeArgv: ?Argv, project: ?Path) => { + const version = + getVersion() + + (__dirname.includes(`packages${path.sep}jest-cli`) ? '-dev' : ''); + const rawArgv: Argv | string[] = maybeArgv || process.argv.slice(2); const argv: Argv = yargs(rawArgv) .usage(args.usage) + .version(version) .alias('help', 'h') .options(args.options) .epilogue(args.docs)