-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: Hide Watch Usage output when running on non-interactive envs (#4958
) * cli: Hide Watch Usage output when running on non-interactive environments * cli: Hide no test found related messages on non-interactive environments * Move isInteractive to jest-util * Use isInteractive in other parts of the code * Fix tests that depend on interactive environment * Fix tests in AppVeyor and add tests to the is_interactive module * Update CHANGELOG for #4958
- Loading branch information
Showing
13 changed files
with
124 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/jest-cli/src/__tests__/__snapshots__/watch.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 12 additions & 6 deletions
18
packages/jest-cli/src/get_no_test_found_related_to_changed_files.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import chalk from 'chalk'; | ||
import {isInteractive} from 'jest-util'; | ||
|
||
export default function getNoTestFoundRelatedToChangedFiles(globalConfig) { | ||
return ( | ||
chalk.bold('No tests found related to files changed since last commit.\n') + | ||
chalk.dim( | ||
globalConfig.watch | ||
let msg = chalk.bold( | ||
'No tests found related to files changed since last commit.', | ||
); | ||
|
||
if (isInteractive) { | ||
msg += chalk.dim( | ||
'\n' + globalConfig.watch | ||
? 'Press `a` to run all tests, or run Jest with `--watchAll`.' | ||
: 'Run Jest without `-o` or with `--all` to run all tests.', | ||
) | ||
); | ||
); | ||
} | ||
|
||
return msg; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
let oldIsTTY; | ||
|
||
beforeEach(() => { | ||
oldIsTTY = process.stdout.isTTY; | ||
}); | ||
|
||
afterEach(() => { | ||
process.stdout.isTTY = oldIsTTY; | ||
jest.resetModules(); | ||
}); | ||
|
||
it('Returns true when running on interactive environment', () => { | ||
jest.doMock('is-ci', () => false); | ||
process.stdout.isTTY = true; | ||
|
||
const isInteractive = require('../is_interative').default; | ||
expect(isInteractive).toBe(true); | ||
}); | ||
|
||
it('Returns false when running on a non-interactive environment', () => { | ||
let isInteractive; | ||
const expectedResult = false; | ||
|
||
// Test with is-ci being true and isTTY false | ||
jest.doMock('is-ci', () => true); | ||
process.stdout.isTTY = false; | ||
isInteractive = require('../is_interative').default; | ||
expect(isInteractive).toBe(expectedResult); | ||
|
||
// Test with is-ci being false and isTTY false | ||
jest.resetModules(); | ||
jest.doMock('is-ci', () => false); | ||
process.stdout.isTTY = false; | ||
isInteractive = require('../is_interative').default; | ||
expect(isInteractive).toBe(expectedResult); | ||
|
||
// Test with is-ci being true and isTTY true | ||
jest.resetModules(); | ||
jest.doMock('is-ci', () => true); | ||
process.stdout.isTTY = true; | ||
isInteractive = require('../is_interative').default; | ||
expect(isInteractive).toBe(expectedResult); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import isCI from 'is-ci'; | ||
|
||
export default process.stdout.isTTY && !isCI; |