mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
[TestUtils.act] fix return result checking (#14758)
* fix .act return value testing when result === null * nit
This commit is contained in:
parent
267ed98146
commit
d1326f466a
|
|
@ -665,6 +665,12 @@ describe('ReactTestUtils', () => {
|
|||
});
|
||||
|
||||
it('warns if you return a value inside act', () => {
|
||||
expect(() => act(() => null)).toWarnDev(
|
||||
[
|
||||
'The callback passed to ReactTestUtils.act(...) function must not return anything.',
|
||||
],
|
||||
{withoutStack: true},
|
||||
);
|
||||
expect(() => act(() => 123)).toWarnDev(
|
||||
[
|
||||
'The callback passed to ReactTestUtils.act(...) function must not return anything.',
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ const ReactTestUtils = {
|
|||
if (__DEV__) {
|
||||
if (result !== undefined) {
|
||||
let addendum;
|
||||
if (typeof result.then === 'function') {
|
||||
if (result !== null && typeof result.then === 'function') {
|
||||
addendum =
|
||||
'\n\nIt looks like you wrote ReactTestUtils.act(async () => ...), ' +
|
||||
'or returned a Promise from the callback passed to it. ' +
|
||||
|
|
|
|||
|
|
@ -878,7 +878,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
|
|||
if (__DEV__) {
|
||||
if (result !== undefined) {
|
||||
let addendum;
|
||||
if (typeof result.then === 'function') {
|
||||
if (result !== null && typeof result.then === 'function') {
|
||||
addendum =
|
||||
"\n\nIt looks like you wrote ReactNoop.act(async () => ...) or returned a Promise from it's callback. " +
|
||||
'Putting asynchronous logic inside ReactNoop.act(...) is not supported.\n';
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ const ReactTestRendererFiber = {
|
|||
if (__DEV__) {
|
||||
if (result !== undefined) {
|
||||
let addendum;
|
||||
if (typeof result.then === 'function') {
|
||||
if (result !== null && typeof result.then === 'function') {
|
||||
addendum =
|
||||
"\n\nIt looks like you wrote TestRenderer.act(async () => ...) or returned a Promise from it's callback. " +
|
||||
'Putting asynchronous logic inside TestRenderer.act(...) is not supported.\n';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user