Skip to content

Commit

Permalink
jest-environment-node: add atob and btoa (#12269)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jan 28, 2022
1 parent 5f71f86 commit 2d8c7c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,8 @@

### Fixes

- `[jest-environment-node]` Add `atob` and `btoa` ([#12269](https://github.com/facebook/jest/pull/12269))

### Chore & Maintenance

- `[*]` Update graceful-fs to ^4.2.9 ([#11749](https://github.com/facebook/jest/pull/11749))
Expand Down
5 changes: 5 additions & 0 deletions packages/jest-environment-node/src/index.ts
Expand Up @@ -82,6 +82,11 @@ class NodeEnvironment implements JestEnvironment<Timer> {
if (typeof performance !== 'undefined') {
global.performance = performance;
}
// atob and btoa are global in Node >= 16
if (typeof atob !== 'undefined' && typeof btoa !== 'undefined') {
global.atob = atob;
global.btoa = btoa;
}
installCommonGlobals(global, config.globals);

this.moduleMocker = new ModuleMocker(global);
Expand Down

0 comments on commit 2d8c7c0

Please sign in to comment.