Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
the prior commit introduced use of TextEncoder which is not available in the jsdom environment for Jest. This change addes the TextEncoder global where necessary to allow previously working tests to continue working
  • Loading branch information
gnoff committed Apr 7, 2022
1 parent 15dc459 commit 7ed1173
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

'use strict';

global.TextEncoder = require('util').TextEncoder;

let JSDOM;
let Stream;
let Scheduler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @emails react-core
*/

global.TextEncoder = require('util').TextEncoder;

let JSDOM;
let React;
let startTransition;
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMUseId-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @emails react-core
*/

global.TextEncoder = require('util').TextEncoder;

let JSDOM;
let React;
let ReactDOMClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

const stream = require('stream');
const shouldIgnoreConsoleError = require('../../../../../scripts/jest/shouldIgnoreConsoleError');
global.TextEncoder = require('util').TextEncoder;

module.exports = function(initModules) {
let ReactDOM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// Polyfills for test environment
global.ReadableStream = require('web-streams-polyfill/ponyfill/es6').ReadableStream;
global.TextDecoder = require('util').TextDecoder;
global.TextEncoder = require('util').TextEncoder;

// Don't wait before processing work on the server.
// TODO: we can replace this with FlightServer.act().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

'use strict';

global.TextEncoder = require('util').TextEncoder;

let React;
let ReactFabric;
let createReactNativeComponentClass;
Expand Down

0 comments on commit 7ed1173

Please sign in to comment.