ReactTestUtilsActUnmockedScheduler-test.js — react Source File
Architecture documentation for ReactTestUtilsActUnmockedScheduler-test.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
// sanity tests to make sure act() works without a mocked scheduler
let React;
let ReactDOMClient;
let act;
let container;
let yields;
let prevActGlobal;
function clearLog() {
try {
return yields;
} finally {
yields = [];
}
}
beforeEach(() => {
prevActGlobal = global.IS_REACT_ACT_ENVIRONMENT;
global.IS_REACT_ACT_ENVIRONMENT = true;
jest.resetModules();
jest.unmock('scheduler');
yields = [];
React = require('react');
ReactDOMClient = require('react-dom/client');
act = React.act;
container = document.createElement('div');
document.body.appendChild(container);
});
afterEach(() => {
global.IS_REACT_ACT_ENVIRONMENT = prevActGlobal;
document.body.removeChild(container);
});
// @gate __DEV__
test('can use act to flush effects', async () => {
function App() {
React.useEffect(() => {
yields.push(100);
});
return null;
}
const root = ReactDOMClient.createRoot(container);
await act(() => {
root.render(<App />);
});
expect(clearLog()).toEqual([100]);
});
// ... (111 more lines)
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does ReactTestUtilsActUnmockedScheduler-test.js do?
ReactTestUtilsActUnmockedScheduler-test.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactTestUtilsActUnmockedScheduler-test.js?
ReactTestUtilsActUnmockedScheduler-test.js defines 1 function(s): clearLog.
Where is ReactTestUtilsActUnmockedScheduler-test.js in the architecture?
ReactTestUtilsActUnmockedScheduler-test.js is located at packages/react-dom/src/__tests__/ReactTestUtilsActUnmockedScheduler-test.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-dom/src/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free