Skip to content

Commit

Permalink
Fix tests mixing environments
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Nov 23, 2021
1 parent cd0dd46 commit 22a2308
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 6 additions & 5 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment node
*/

'use strict';
Expand All @@ -21,8 +22,6 @@ let useSyncExternalStore;
let useSyncExternalStoreWithSelector;
let PropTypes;
let textCache;
let window;
let document;
let writable;
let CSPnonce = null;
let container;
Expand All @@ -36,7 +35,6 @@ describe('ReactDOMFizzServer', () => {
JSDOM = require('jsdom').JSDOM;
Scheduler = require('scheduler');
React = require('react');
ReactDOM = require('react-dom');
if (__EXPERIMENTAL__) {
ReactDOMFizzServer = require('react-dom/server');
}
Expand Down Expand Up @@ -71,8 +69,11 @@ describe('ReactDOMFizzServer', () => {
runScripts: 'dangerously',
},
);
window = jsdom.window;
document = jsdom.window.document;
global.window = jsdom.window;
global.document = jsdom.window.document;
global.navigator = jsdom.window.navigator;
ReactDOM = require('react-dom');

container = document.getElementById('container');

buffer = '';
Expand Down
9 changes: 6 additions & 3 deletions packages/react-dom/src/__tests__/ReactDOMUseId-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment node
*/

let JSDOM;
Expand All @@ -17,7 +18,6 @@ let Stream;
let Suspense;
let useId;
let useState;
let document;
let writable;
let container;
let buffer = '';
Expand All @@ -29,7 +29,6 @@ describe('useId', () => {
jest.resetModules();
JSDOM = require('jsdom').JSDOM;
React = require('react');
ReactDOM = require('react-dom');
Scheduler = require('scheduler');
clientAct = require('jest-react').act;
ReactDOMFizzServer = require('react-dom/server');
Expand All @@ -45,7 +44,11 @@ describe('useId', () => {
runScripts: 'dangerously',
},
);
document = jsdom.window.document;
global.window = jsdom.window;
global.document = jsdom.window.document;
global.navigator = jsdom.window.navigator;
ReactDOM = require('react-dom');

container = document.getElementById('container');

buffer = '';
Expand Down

0 comments on commit 22a2308

Please sign in to comment.