Skip to content

Commit

Permalink
Use separate feature flag for ReactTestRenderer (facebook#8965)
Browse files Browse the repository at this point in the history
The ReactDOMFeatureFlags is not reachable from the npm package since it is
in a separate build so we need a separate one.
  • Loading branch information
sebmarkbage authored and gaearon committed Feb 9, 2017
1 parent ab757e9 commit 13e05b4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions scripts/jest/test-framework-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ jest.mock('ReactNativeFeatureFlags', () => {
useFiber: flags.useFiber || !!process.env.REACT_DOM_JEST_USE_FIBER,
});
});
jest.mock('ReactTestRendererFeatureFlags', () => {
const flags = require.requireActual('ReactTestRendererFeatureFlags');
return Object.assign({}, flags, {
useFiber: flags.useFiber || !!process.env.REACT_DOM_JEST_USE_FIBER,
});
});

// Error logging varies between Fiber and Stack;
// Rather than fork dozens of tests, mock the error-logging file by default.
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/testing/ReactTestRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

'use strict';

const ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
const ReactTestRendererFeatureFlags = require('ReactTestRendererFeatureFlags');

module.exports = ReactDOMFeatureFlags.useFiber
module.exports = ReactTestRendererFeatureFlags.useFiber
? require('ReactTestRendererFiber')
: require('ReactTestRendererStack');
18 changes: 18 additions & 0 deletions src/renderers/testing/ReactTestRendererFeatureFlags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ReactTestRendererFeatureFlags
*/

'use strict';

var ReactTestRendererFeatureFlags = {
useFiber: false,
};

module.exports = ReactTestRendererFeatureFlags;

0 comments on commit 13e05b4

Please sign in to comment.