-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create shared mock for scheduler (#4313)
Summary: The version of scheduler we get internally is always the latest. However, on GitHub we get the version is a transitive dependency from `react-test-renderer`. Some methods in the unstable_mock have been renamed between these two versions. This mock file provides a centralized place to reconcile those differences so that the same tests can work both internally and on GitHub. I also tried manually upgrading `react-test-renderer` to the `experimental` tag in the hopes of getting GitHub to use the same version we have internally, and then transitively inherit the more recent version of `scheduler`. Unfortunately that created many test failures for reasons I don't currently fully understand. Pull Request resolved: #4313 Reviewed By: voideanvalue Differential Revision: D45789944 Pulled By: captbaritone fbshipit-source-id: 1e2a0fb47667cd12bdbe13d9f819015a8d545f13
- Loading branch information
1 parent
e784ee4
commit cc1daa1
Showing
13 changed files
with
48 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* 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. | ||
* | ||
* @flow | ||
* @format | ||
* @oncall relay | ||
*/ | ||
|
||
const invariant = require('invariant'); | ||
const Scheduler = require('scheduler/unstable_mock'); | ||
|
||
// The version of scheduler we get internally is always the latest. However, the | ||
// version we get on GitHub is a transitive dependency from `react-test-renderer`. | ||
// | ||
// Some methods in the unstable_mock have been renamed between these two | ||
// versions. This mock file provides a centralized place to reconcile those | ||
// differences so that the same tests can work both internally and on GitHub. | ||
|
||
if (Scheduler.log == null) { | ||
invariant( | ||
Scheduler.unstable_yieldValue != null, | ||
'Expected to find one of log or unstable_yieldValue', | ||
); | ||
Scheduler.log = Scheduler.unstable_yieldValue; | ||
} | ||
if (Scheduler.unstable_clearLog == null) { | ||
invariant( | ||
Scheduler.unstable_clearYields != null, | ||
'Expected to find one of unstable_clearLog or unstable_clearYields', | ||
); | ||
Scheduler.unstable_clearLog = Scheduler.unstable_clearYields; | ||
} | ||
module.exports = Scheduler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters