@samitouri / QOS-React / commits / ebbd221432

Configure react-test-renderer as a secondary (#13164)

Brandon Dail committed Jul 6, 2018 at 16:04 UTC ebbd2214326ca6a5f24f46ea7eaffc6cfabbbe1c
3 files changed +28 -8
packages/react-art/src/__tests__/ReactART-test.js
+8 -7
@@ -28,6 +28,10 @@ const Circle = require('react-art/Circle');
28 const Rectangle = require('react-art/Rectangle');
29 const Wedge = require('react-art/Wedge');
30
31 +// Isolate the noop renderer
32 +jest.resetModules();
33 +const ReactNoop = require('react-noop-renderer');
34 +
35 let Group;
36 let Shape;
37 let Surface;
@@ -354,7 +358,7 @@ describe('ReactART', () => {
358 const CurrentRendererContext = React.createContext(null);
359
360 function Yield(props) {
357 - testRenderer.unstable_yield(props.value);
361 + ReactNoop.yield(props.value);
362 return null;
363 }
364
@@ -372,19 +376,16 @@ describe('ReactART', () => {
376
377 // Using test renderer instead of the DOM renderer here because async
378 // testing APIs for the DOM renderer don't exist.
375 - const testRenderer = ReactTestRenderer.create(
379 + ReactNoop.render(
380 <CurrentRendererContext.Provider value="Test">
381 <Yield value="A" />
382 <Yield value="B" />
383 <LogCurrentRenderer />
384 <Yield value="C" />
385 </CurrentRendererContext.Provider>,
382 - {
383 - unstable_isAsync: true,
384 - },
386 );
387
387 - testRenderer.unstable_flushThrough(['A']);
388 + ReactNoop.flushThrough(['A']);
389
390 ReactDOM.render(
391 <Surface>
@@ -399,7 +400,7 @@ describe('ReactART', () => {
400 expect(ops).toEqual([null, 'ART']);
401
402 ops = [];
402 - expect(testRenderer.unstable_flushAll()).toEqual(['B', 'C']);
403 + expect(ReactNoop.flush()).toEqual(['B', 'C']);
404
405 expect(ops).toEqual(['Test']);
406 });
packages/react-test-renderer/src/ReactTestHostConfig.js
+1 -1
@@ -180,7 +180,7 @@ export function createTextInstance(
180 };
181 }
182
183 -export const isPrimaryRenderer = true;
183 +export const isPrimaryRenderer = false;
184 // This approach enables `now` to be mocked by tests,
185 // Even after the reconciler has initialized and read host config values.
186 export const now = () => TestRendererScheduling.nowImplementation();
packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js
+19
@@ -16,6 +16,10 @@ const React = require('react');
16 const ReactTestRenderer = require('react-test-renderer');
17 const prettyFormat = require('pretty-format');
18
19 +// Isolate noop renderer
20 +jest.resetModules();
21 +const ReactNoop = require('react-noop-renderer');
22 +
23 // Kind of hacky, but we nullify all the instances to test the tree structure
24 // with jasmine's deep equality function, and test the instances separate. We
25 // also delete children props because testing them is more annoying and not
@@ -1000,4 +1004,19 @@ describe('ReactTestRenderer', () => {
1004 }),
1005 );
1006 });
1007 +
1008 + it('can concurrently render context with a "primary" renderer', () => {
1009 + const Context = React.createContext(null);
1010 + const Indirection = React.Fragment;
1011 + const App = () => (
1012 + <Context.Provider>
1013 + <Indirection>
1014 + <Context.Consumer>{() => null}</Context.Consumer>
1015 + </Indirection>
1016 + </Context.Provider>
1017 + );
1018 + ReactNoop.render(<App />);
1019 + ReactNoop.flush();
1020 + ReactTestRenderer.create(<App />);
1021 + });
1022 });