Skip to content

Commit

Permalink
Treat dumb terminals as noninteractive (#5237)
Browse files Browse the repository at this point in the history
* Treat dumb terminals as noninteractive

* Add basic changelog entry
  • Loading branch information
nickserv authored and cpojer committed Jan 5, 2018
1 parent 586064d commit 9cbc26b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Fixes

* `[jest-cli]` Treat dumb terminals as noninteractive ([#5237](https://github.com/facebook/jest/pull/5237))
* `[jest-cli]` `jest --onlyChanged --changedFilesWithAncestor` now also works
with git. ([#5189](https://github.com/facebook/jest/pull/5189))
* `[jest-config]` fix unexpected condition to avoid infinite recursion in
Expand Down
15 changes: 15 additions & 0 deletions packages/jest-util/src/__tests__/is_interactive.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
let oldIsTTY;
let oldTERM;

beforeEach(() => {
oldIsTTY = process.stdout.isTTY;
oldTERM = process.env.TERM;
});

afterEach(() => {
process.stdout.isTTY = oldIsTTY;
process.env.TERM = oldTERM;
jest.resetModules();
});

it('Returns true when running on interactive environment', () => {
jest.doMock('is-ci', () => false);
process.stdout.isTTY = true;
process.env.TERM = 'xterm-256color';

const isInteractive = require('../is_interative').default;
expect(isInteractive).toBe(true);
Expand All @@ -24,20 +28,31 @@ it('Returns false when running on a non-interactive environment', () => {
// Test with is-ci being true and isTTY false
jest.doMock('is-ci', () => true);
process.stdout.isTTY = false;
process.env.TERM = 'xterm-256color';
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;
process.env.TERM = 'xterm-256color';
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;
process.env.TERM = 'xterm-256color';
isInteractive = require('../is_interative').default;
expect(isInteractive).toBe(expectedResult);

// Test with dumb terminal
jest.resetModules();
jest.doMock('is-ci', () => false);
process.stdout.isTTY = false;
process.env.TERM = 'dumb';
isInteractive = require('../is_interative').default;
expect(isInteractive).toBe(expectedResult);
});
2 changes: 1 addition & 1 deletion packages/jest-util/src/is_interative.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import isCI from 'is-ci';

export default process.stdout.isTTY && !isCI;
export default process.stdout.isTTY && process.env.TERM !== 'dumb' && !isCI;

0 comments on commit 9cbc26b

Please sign in to comment.