Skip to content

Commit 976f7b8

Browse files
authored
Configure react-test-renderer as a secondary (#13164)
1 parent 17c7e1e commit 976f7b8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/ReactTestHostConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export function createTextInstance(
180180
};
181181
}
182182

183-
export const isPrimaryRenderer = true;
183+
export const isPrimaryRenderer = false;
184184
// This approach enables `now` to be mocked by tests,
185185
// Even after the reconciler has initialized and read host config values.
186186
export const now = () => TestRendererScheduling.nowImplementation();

src/__tests__/ReactTestRenderer-test.internal.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const React = require('react');
1616
const ReactTestRenderer = require('react-test-renderer');
1717
const prettyFormat = require('pretty-format');
1818

19+
// Isolate noop renderer
20+
jest.resetModules();
21+
const ReactNoop = require('react-noop-renderer');
22+
1923
// Kind of hacky, but we nullify all the instances to test the tree structure
2024
// with jasmine's deep equality function, and test the instances separate. We
2125
// also delete children props because testing them is more annoying and not
@@ -1000,4 +1004,19 @@ describe('ReactTestRenderer', () => {
10001004
}),
10011005
);
10021006
});
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+
});
10031022
});

0 commit comments

Comments
 (0)