SchedulerSetImmediate-test.js — react Source File
Architecture documentation for SchedulerSetImmediate-test.js, a javascript file in the react codebase.
Entity Profile
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
* @jest-environment node
*/
'use strict';
let Scheduler;
let runtime;
let performance;
let cancelCallback;
let scheduleCallback;
let NormalPriority;
let UserBlockingPriority;
// The Scheduler implementation uses browser APIs like `MessageChannel` and
// `setTimeout` to schedule work on the main thread. Most of our tests treat
// these as implementation details; however, the sequence and timing of these
// APIs are not precisely specified, and can vary across browsers.
//
// To prevent regressions, we need the ability to simulate specific edge cases
// that we may encounter in various browsers.
//
// This test suite mocks all browser methods used in our implementation. It
// assumes as little as possible about the order and timing of events.
describe('SchedulerDOMSetImmediate', () => {
beforeEach(() => {
jest.resetModules();
runtime = installMockBrowserRuntime();
jest.unmock('scheduler');
performance = global.performance;
Scheduler = require('scheduler');
cancelCallback = Scheduler.unstable_cancelCallback;
scheduleCallback = Scheduler.unstable_scheduleCallback;
NormalPriority = Scheduler.unstable_NormalPriority;
UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
});
afterEach(() => {
delete global.performance;
if (!runtime.isLogEmpty()) {
throw Error('Test exited without clearing log.');
}
});
function installMockBrowserRuntime() {
let timerIDCounter = 0;
// let timerIDs = new Map();
let eventLog = [];
let currentTime = 0;
// ... (260 more lines)
Source
Frequently Asked Questions
What does SchedulerSetImmediate-test.js do?
SchedulerSetImmediate-test.js is a source file in the react codebase, written in javascript.
Where is SchedulerSetImmediate-test.js in the architecture?
SchedulerSetImmediate-test.js is located at packages/scheduler/src/__tests__/SchedulerSetImmediate-test.js (directory: packages/scheduler/src/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free