Skip to content

Commit

Permalink
Fixed ReactFresh test/mock
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Apr 26, 2021
1 parent 6f3ea70 commit 104fdc5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/react-reconciler/src/__mocks__/scheduler/tracing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

// This placeholder is to support a legacy/regression test in ReactFresh-test.
// Without this mock, jest.mock('scheduler/tracing') throws.
3 changes: 2 additions & 1 deletion packages/react-refresh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"devDependencies": {
"react-16-8": "npm:[email protected]",
"react-dom-16-8": "npm:[email protected]"
"react-dom-16-8": "npm:[email protected]",
"scheduler-0-13": "npm:[email protected]"
}
}
4 changes: 4 additions & 0 deletions packages/react-refresh/src/__tests__/ReactFresh-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3844,6 +3844,10 @@ describe('ReactFresh', () => {

// Redirect all React/ReactDOM requires to v16.8.0
// This version predates Fast Refresh support.
jest.mock('scheduler', () => jest.requireActual('scheduler-0-13'));
jest.mock('scheduler/tracing', () =>
jest.requireActual('scheduler-0-13/tracing'),
);
jest.mock('react', () => jest.requireActual('react-16-8'));
jest.mock('react-dom', () => jest.requireActual('react-dom-16-8'));

Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12319,6 +12319,14 @@ saxes@^5.0.0:
dependencies:
xmlchars "^2.2.0"

"scheduler-0-13@npm:[email protected]":
version "0.13.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.0.tgz#e701f62e1b3e78d2bbb264046d4e7260f12184dd"
integrity sha512-w7aJnV30jc7OsiZQNPVmBc+HooZuvQZIZIShKutC3tnMFMkcwVN9CZRRSSNw03OnSCKmEkK8usmwcw6dqBaLzw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"

scheduler@^0.11.0:
version "0.11.3"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.11.3.tgz#b5769b90cf8b1464f3f3cfcafe8e3cd7555a2d6b"
Expand Down

0 comments on commit 104fdc5

Please sign in to comment.