diff --git a/src/renderers/testing/__tests__/ReactTestRenderer-test.js b/src/renderers/testing/__tests__/ReactTestRenderer-test.js index ce64455e4a4cb..c4fb9f77370a2 100644 --- a/src/renderers/testing/__tests__/ReactTestRenderer-test.js +++ b/src/renderers/testing/__tests__/ReactTestRenderer-test.js @@ -568,7 +568,7 @@ describe('ReactTestRenderer', () => { }); }); - it('toTree() renders complicated trees of composites and hosts', () => { + fit('toTree() renders complicated trees of composites and hosts', () => { // SFC returning host. no children props. var Qoo = () => Hello World!; diff --git a/src/renderers/testing/stack/ReactTestRendererStack.js b/src/renderers/testing/stack/ReactTestRendererStack.js index f87b0383bd2a8..02b759adc0472 100644 --- a/src/renderers/testing/stack/ReactTestRendererStack.js +++ b/src/renderers/testing/stack/ReactTestRendererStack.js @@ -36,6 +36,31 @@ type ReactTestRendererJSON = { $$typeof?: any, }; +let injected = false; +function inject() { + if (injected) { + return; + } + + injected = true; + + ReactUpdates.injection.injectReconcileTransaction( + ReactTestReconcileTransaction, + ); + ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy); + + ReactHostComponent.injection.injectGenericComponentClass(ReactTestComponent); + ReactHostComponent.injection.injectTextComponentClass(ReactTestTextComponent); + ReactEmptyComponent.injection.injectEmptyComponentFactory(function() { + return new ReactTestEmptyComponent(); + }); + + ReactComponentEnvironment.injection.injectEnvironment({ + processChildrenUpdates: function() {}, + replaceNodeWithMarkup: function() {}, + }); +} + /** * Drill down (through composites and empty components) until we get a native or * native text component. @@ -134,24 +159,12 @@ Object.assign(ReactTestComponent.prototype, ReactMultiChild); // ============================================================================= -ReactUpdates.injection.injectReconcileTransaction( - ReactTestReconcileTransaction, -); -ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy); - -ReactHostComponent.injection.injectGenericComponentClass(ReactTestComponent); -ReactHostComponent.injection.injectTextComponentClass(ReactTestTextComponent); -ReactEmptyComponent.injection.injectEmptyComponentFactory(function() { - return new ReactTestEmptyComponent(); -}); - -ReactComponentEnvironment.injection.injectEnvironment({ - processChildrenUpdates: function() {}, - replaceNodeWithMarkup: function() {}, -}); - var ReactTestRenderer = { - create: ReactTestMount.render, + create: () => { + inject(); + + return ReactTestMount.render(); + }, /* eslint-disable camelcase */ unstable_batchedUpdates: ReactUpdates.batchedUpdates, /* eslint-enable camelcase */