Skip to content

Commit

Permalink
Handle different error counts depending on renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Jan 28, 2024
1 parent d1eb303 commit d0fada2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ function initModules() {
};
}

const {resetModules, itRenders, itThrowsWhenRendering, serverRender} =
ReactDOMServerIntegrationUtils(initModules);
const {
resetModules,
itRenders,
itThrowsWhenRendering,
clientRenderOnBadMarkup,
serverRender,
} = ReactDOMServerIntegrationUtils(initModules);

describe('ReactDOMServerHooks', () => {
beforeEach(() => {
Expand Down Expand Up @@ -422,8 +427,13 @@ describe('ReactDOMServerHooks', () => {
});
return 'hi';
}
// TODO: fails due to render error retry
const domNode = await render(<App />, 1);
const domNode = await render(
<App />,
render === clientRenderOnBadMarkup
? // On hydration mismatch we retry and therefore log the warning again.
2
: 1,
);
expect(domNode.textContent).toEqual('hi');
});

Expand All @@ -436,8 +446,13 @@ describe('ReactDOMServerHooks', () => {
return value;
}

// TODO: fails due to render error retry
const domNode = await render(<App />, 1);
const domNode = await render(
<App />,
render === clientRenderOnBadMarkup
? // On hydration mismatch we retry and therefore log the warning again.
2
: 1,
);
expect(domNode.textContent).toEqual('0');
});
});
Expand Down Expand Up @@ -860,11 +875,15 @@ describe('ReactDOMServerHooks', () => {
return <Text text={count} />;
}

// TODO: fails due to render error retry
const domNode1 = await render(<ReadInMemo />, 1);
const domNode1 = await render(
<ReadInMemo />,
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(<ReadInReducer />, 1);
expect(domNode2.textContent).toEqual('42');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function initModules() {
};
}

const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules);
const {resetModules, itRenders, clientRenderOnBadMarkup} =
ReactDOMServerIntegrationUtils(initModules);

describe('ReactDOMServerIntegration', () => {
beforeEach(() => {
Expand Down Expand Up @@ -365,9 +366,13 @@ describe('ReactDOMServerIntegration', () => {
</div>
);
};
// TODO: fails due to render error retry
// We expect 1 error.
await render(<App />, 1);
await render(
<App />,
render === clientRenderOnBadMarkup
? // On hydration mismatch we retry and therefore log the warning again.
2
: 1,
);
},
);

Expand All @@ -392,9 +397,14 @@ describe('ReactDOMServerIntegration', () => {
</div>
);
};
// TODO: fails due to render error retry
// We expect 1 error.
await render(<App />, 1);

await render(
<App />,
render === clientRenderOnBadMarkup
? // On hydration mismatch we retry and therefore log the warning again.
2
: 1,
);
},
);

Expand Down

0 comments on commit d0fada2

Please sign in to comment.