Skip to content

Commit

Permalink
fix(jest-util): make sure isInteractive works in a browser (#14552)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Sep 20, 2023
1 parent 4f35f1f commit f38c05c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- `[babel-plugin-jest-hoist]` Use `denylist` instead of the deprecated `blacklist` for Babel 8 support ([#14109](https://github.com/jestjs/jest/pull/14109))
- `[@jest/expect-utils]` Fix comparison of `DataView` ([#14408](https://github.com/jestjs/jest/pull/14408))
- `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))
- `[jest-util]` Make sure `isInteractive` works in a browser ([#14552](https://github.com/jestjs/jest/pull/14552))
- `[pretty-format]` [**BREAKING**] Print `ArrayBuffer` and `DataView` correctly ([#14290](https://github.com/facebook/jest/pull/14290))

### Performance
Expand Down
21 changes: 20 additions & 1 deletion packages/jest-util/src/isInteractive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,23 @@

import {isCI} from 'ci-info';

export default !!process.stdout.isTTY && process.env.TERM !== 'dumb' && !isCI;
function checkIsInteractive(): boolean {
if (isCI) {
return false;
}

// this can happen in a browser with polyfills: https://github.com/defunctzombie/node-process/issues/41
if (process.stdout == null) {
return false;
}

if (process.stdout.isTTY) {
return process.env.TERM !== 'dumb';
}

return false;
}

const isInteractive = checkIsInteractive();

export default isInteractive;

0 comments on commit f38c05c

Please sign in to comment.