Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing TextEncoder and TextDecoder to jest-envirotment-node #8022

Merged
merged 3 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Fixes

- `[jest-environment-node]` Add mising globals: TextEncoder and TextDecoder ([#8022](https://github.com/facebook/jest/pull/8022))
- `[jest-cli]` Fix prototype pollution vulnerability in dependency ([#7904](https://github.com/facebook/jest/pull/7904))
- `[jest-cli]` Refactor `-o` and `--coverage` combined ([#7611](https://github.com/facebook/jest/pull/7611))
- `[expect]` Fix custom async matcher stack trace ([#7652](https://github.com/facebook/jest/pull/7652))
Expand Down
9 changes: 9 additions & 0 deletions packages/jest-environment-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ class NodeEnvironment implements JestEnvironment {
global.URL = URL;
global.URLSearchParams = URLSearchParams;
}
// TextDecoder and TextDecoder are global in Node >= 11
if (
typeof TextEncoder !== 'undefined' &&
typeof TextDecoder !== 'undefined'
) {
/* global TextEncoder, TextDecoder */
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
}
installCommonGlobals(global, config.globals);
this.moduleMocker = new ModuleMocker(global);

Expand Down