Skip to content

Commit f38c05c

Browse files
authored
fix(jest-util): make sure isInteractive works in a browser (#14552)
1 parent 4f35f1f commit f38c05c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- `[babel-plugin-jest-hoist]` Use `denylist` instead of the deprecated `blacklist` for Babel 8 support ([#14109](https://github.com/jestjs/jest/pull/14109))
1616
- `[@jest/expect-utils]` Fix comparison of `DataView` ([#14408](https://github.com/jestjs/jest/pull/14408))
1717
- `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))
18+
- `[jest-util]` Make sure `isInteractive` works in a browser ([#14552](https://github.com/jestjs/jest/pull/14552))
1819
- `[pretty-format]` [**BREAKING**] Print `ArrayBuffer` and `DataView` correctly ([#14290](https://github.com/facebook/jest/pull/14290))
1920

2021
### Performance

packages/jest-util/src/isInteractive.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,23 @@
77

88
import {isCI} from 'ci-info';
99

10-
export default !!process.stdout.isTTY && process.env.TERM !== 'dumb' && !isCI;
10+
function checkIsInteractive(): boolean {
11+
if (isCI) {
12+
return false;
13+
}
14+
15+
// this can happen in a browser with polyfills: https://github.com/defunctzombie/node-process/issues/41
16+
if (process.stdout == null) {
17+
return false;
18+
}
19+
20+
if (process.stdout.isTTY) {
21+
return process.env.TERM !== 'dumb';
22+
}
23+
24+
return false;
25+
}
26+
27+
const isInteractive = checkIsInteractive();
28+
29+
export default isInteractive;

0 commit comments

Comments
 (0)