Skip to content

Commit

Permalink
Fix ReactTestRenderer-test.internal
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Pope committed Mar 21, 2024
1 parent a2ce03c commit e73df6e
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ describe('ReactTestRenderer', () => {
});

// @gate !enableRefAsProp || !__DEV__
it('warns correctly for refs on SFCs', () => {
it('warns correctly for refs on SFCs', async () => {
function Bar() {
return <div>Hello, world</div>;
}
Expand All @@ -339,8 +339,14 @@ describe('ReactTestRenderer', () => {
return <div ref={this.bazRef} />;
}
}
ReactTestRenderer.create(<Baz />);
expect(() => ReactTestRenderer.create(<Foo />)).toErrorDev(
await act(() => {
ReactTestRenderer.create(<Baz />);
});
await expect(async () => {
await act(() => {
ReactTestRenderer.create(<Foo />);
});
}).toErrorDev(
'Warning: Function components cannot be given refs. Attempts ' +
'to access this ref will fail. ' +
'Did you mean to use React.forwardRef()?\n' +
Expand Down

0 comments on commit e73df6e

Please sign in to comment.