From 110637ae4a7d2f20ccaac6592bc2b69e2d334b95 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 28 Jan 2024 11:00:32 +0100 Subject: [PATCH] Handle different error counts depending on renderer --- .../ReactDOMServerIntegrationHooks-test.js | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js index ac98730d4b656..7e46bea5f93d9 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js @@ -73,8 +73,13 @@ function initModules() { }; } -const {resetModules, itRenders, itThrowsWhenRendering, serverRender} = - ReactDOMServerIntegrationUtils(initModules); +const { + resetModules, + itRenders, + itThrowsWhenRendering, + clientRenderOnBadMarkup, + serverRender, +} = ReactDOMServerIntegrationUtils(initModules); describe('ReactDOMServerHooks', () => { beforeEach(() => { @@ -422,8 +427,13 @@ describe('ReactDOMServerHooks', () => { }); return 'hi'; } - // TODO: fails due to render error retry - const domNode = await render(, 1); + const domNode = await render( + , + render === clientRenderOnBadMarkup + ? // On hydration mismatch we retry and therefore log the warning again. + 2 + : 1, + ); expect(domNode.textContent).toEqual('hi'); }); @@ -436,8 +446,13 @@ describe('ReactDOMServerHooks', () => { return value; } - // TODO: fails due to render error retry - const domNode = await render(, 1); + const domNode = await render( + , + render === clientRenderOnBadMarkup + ? // On hydration mismatch we retry and therefore log the warning again. + 2 + : 1, + ); expect(domNode.textContent).toEqual('0'); }); }); @@ -860,11 +875,15 @@ describe('ReactDOMServerHooks', () => { return ; } - // TODO: fails due to render error retry - const domNode1 = await render(, 1); + const domNode1 = await render( + , + render === clientRenderOnBadMarkup + ? // On hydration mismatch we retry and therefore log the warning again. + 2 + : 1, + ); expect(domNode1.textContent).toEqual('42'); - // TODO: fails due to render error retry const domNode2 = await render(, 1); expect(domNode2.textContent).toEqual('42'); });