Skip to content

Commit 9cbc26b

Browse files
nickservcpojer
authored andcommitted
Treat dumb terminals as noninteractive (#5237)
* Treat dumb terminals as noninteractive * Add basic changelog entry
1 parent 586064d commit 9cbc26b

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Fixes
44

5+
* `[jest-cli]` Treat dumb terminals as noninteractive ([#5237](https://github.com/facebook/jest/pull/5237))
56
* `[jest-cli]` `jest --onlyChanged --changedFilesWithAncestor` now also works
67
with git. ([#5189](https://github.com/facebook/jest/pull/5189))
78
* `[jest-config]` fix unexpected condition to avoid infinite recursion in

packages/jest-util/src/__tests__/is_interactive.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
let oldIsTTY;
2+
let oldTERM;
23

34
beforeEach(() => {
45
oldIsTTY = process.stdout.isTTY;
6+
oldTERM = process.env.TERM;
57
});
68

79
afterEach(() => {
810
process.stdout.isTTY = oldIsTTY;
11+
process.env.TERM = oldTERM;
912
jest.resetModules();
1013
});
1114

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

1620
const isInteractive = require('../is_interative').default;
1721
expect(isInteractive).toBe(true);
@@ -24,20 +28,31 @@ it('Returns false when running on a non-interactive environment', () => {
2428
// Test with is-ci being true and isTTY false
2529
jest.doMock('is-ci', () => true);
2630
process.stdout.isTTY = false;
31+
process.env.TERM = 'xterm-256color';
2732
isInteractive = require('../is_interative').default;
2833
expect(isInteractive).toBe(expectedResult);
2934

3035
// Test with is-ci being false and isTTY false
3136
jest.resetModules();
3237
jest.doMock('is-ci', () => false);
3338
process.stdout.isTTY = false;
39+
process.env.TERM = 'xterm-256color';
3440
isInteractive = require('../is_interative').default;
3541
expect(isInteractive).toBe(expectedResult);
3642

3743
// Test with is-ci being true and isTTY true
3844
jest.resetModules();
3945
jest.doMock('is-ci', () => true);
4046
process.stdout.isTTY = true;
47+
process.env.TERM = 'xterm-256color';
48+
isInteractive = require('../is_interative').default;
49+
expect(isInteractive).toBe(expectedResult);
50+
51+
// Test with dumb terminal
52+
jest.resetModules();
53+
jest.doMock('is-ci', () => false);
54+
process.stdout.isTTY = false;
55+
process.env.TERM = 'dumb';
4156
isInteractive = require('../is_interative').default;
4257
expect(isInteractive).toBe(expectedResult);
4358
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import isCI from 'is-ci';
22

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

0 commit comments

Comments
 (0)