Suppress act() warnings in DevTools tests (#23192)
These warnings are not useful for DevTools tests– and sometimes may mask other, important warnings. This commit disables them.
This commit is contained in:
parent
934f72221d
commit
3d1e7e7278
|
@ -19,7 +19,7 @@ describe('editing interface', () => {
|
||||||
let utils;
|
let utils;
|
||||||
|
|
||||||
const flushPendingUpdates = () => {
|
const flushPendingUpdates = () => {
|
||||||
jest.runOnlyPendingTimers();
|
utils.act(() => jest.runOnlyPendingTimers());
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -71,8 +71,10 @@ describe('InspectedElement', () => {
|
||||||
.TreeContextController;
|
.TreeContextController;
|
||||||
|
|
||||||
// Used by inspectElementAtIndex() helper function
|
// Used by inspectElementAtIndex() helper function
|
||||||
testRendererInstance = TestRenderer.create(null, {
|
utils.act(() => {
|
||||||
unstable_isConcurrent: true,
|
testRendererInstance = TestRenderer.create(null, {
|
||||||
|
unstable_isConcurrent: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
errorBoundaryInstance = null;
|
errorBoundaryInstance = null;
|
||||||
|
@ -299,9 +301,14 @@ describe('InspectedElement', () => {
|
||||||
// from props like defaultSelectedElementID and it's easier to reset here than
|
// from props like defaultSelectedElementID and it's easier to reset here than
|
||||||
// to read the TreeDispatcherContext and update the selected ID that way.
|
// to read the TreeDispatcherContext and update the selected ID that way.
|
||||||
// We're testing the inspected values here, not the context wiring, so that's ok.
|
// We're testing the inspected values here, not the context wiring, so that's ok.
|
||||||
testRendererInstance = TestRenderer.create(null, {
|
utils.withErrorsOrWarningsIgnored(
|
||||||
unstable_isConcurrent: true,
|
['An update to %s inside a test was not wrapped in act'],
|
||||||
});
|
() => {
|
||||||
|
testRendererInstance = TestRenderer.create(null, {
|
||||||
|
unstable_isConcurrent: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const inspectedElement = await inspectElementAtIndex(index);
|
const inspectedElement = await inspectElementAtIndex(index);
|
||||||
|
|
||||||
|
@ -460,9 +467,14 @@ describe('InspectedElement', () => {
|
||||||
// The backend still thinks the most recently-inspected element is still cached,
|
// The backend still thinks the most recently-inspected element is still cached,
|
||||||
// so the frontend needs to tell it to resend a full value.
|
// so the frontend needs to tell it to resend a full value.
|
||||||
// We can verify this by asserting that the component is re-rendered again.
|
// We can verify this by asserting that the component is re-rendered again.
|
||||||
testRendererInstance = TestRenderer.create(null, {
|
utils.withErrorsOrWarningsIgnored(
|
||||||
unstable_isConcurrent: true,
|
['An update to %s inside a test was not wrapped in act'],
|
||||||
});
|
() => {
|
||||||
|
testRendererInstance = TestRenderer.create(null, {
|
||||||
|
unstable_isConcurrent: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
clearCacheForTests,
|
clearCacheForTests,
|
||||||
|
@ -2024,9 +2036,14 @@ describe('InspectedElement', () => {
|
||||||
// from props like defaultSelectedElementID and it's easier to reset here than
|
// from props like defaultSelectedElementID and it's easier to reset here than
|
||||||
// to read the TreeDispatcherContext and update the selected ID that way.
|
// to read the TreeDispatcherContext and update the selected ID that way.
|
||||||
// We're testing the inspected values here, not the context wiring, so that's ok.
|
// We're testing the inspected values here, not the context wiring, so that's ok.
|
||||||
testRendererInstance = TestRenderer.create(null, {
|
utils.withErrorsOrWarningsIgnored(
|
||||||
unstable_isConcurrent: true,
|
['An update to %s inside a test was not wrapped in act'],
|
||||||
});
|
() => {
|
||||||
|
testRendererInstance = TestRenderer.create(null, {
|
||||||
|
unstable_isConcurrent: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// Select/inspect the same element again
|
// Select/inspect the same element again
|
||||||
inspectedElement = await inspectElementAtIndex(0);
|
inspectedElement = await inspectElementAtIndex(0);
|
||||||
|
@ -2743,11 +2760,15 @@ describe('InspectedElement', () => {
|
||||||
0,
|
0,
|
||||||
): any): number);
|
): any): number);
|
||||||
const inspect = index => {
|
const inspect = index => {
|
||||||
// HACK: Recreate TestRenderer instance so we can inspect different
|
// HACK: Recreate TestRenderer instance so we can inspect different elements
|
||||||
// elements
|
utils.withErrorsOrWarningsIgnored(
|
||||||
testRendererInstance = TestRenderer.create(null, {
|
['An update to %s inside a test was not wrapped in act'],
|
||||||
unstable_isConcurrent: true,
|
() => {
|
||||||
});
|
testRendererInstance = TestRenderer.create(null, {
|
||||||
|
unstable_isConcurrent: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
return inspectElementAtIndex(index);
|
return inspectElementAtIndex(index);
|
||||||
};
|
};
|
||||||
const toggleError = async forceError => {
|
const toggleError = async forceError => {
|
||||||
|
|
|
@ -66,9 +66,13 @@ env.beforeEach(() => {
|
||||||
if (typeof firstArg !== 'string') {
|
if (typeof firstArg !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return global._ignoredErrorOrWarningMessages.some(errorOrWarningMessage => {
|
const shouldFilter = global._ignoredErrorOrWarningMessages.some(
|
||||||
return firstArg.indexOf(errorOrWarningMessage) !== -1;
|
errorOrWarningMessage => {
|
||||||
});
|
return firstArg.indexOf(errorOrWarningMessage) !== -1;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return shouldFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
const originalConsoleError = console.error;
|
const originalConsoleError = console.error;
|
||||||
|
@ -82,7 +86,15 @@ env.beforeEach(() => {
|
||||||
throw args[1];
|
throw args[1];
|
||||||
} else if (
|
} else if (
|
||||||
typeof firstArg === 'string' &&
|
typeof firstArg === 'string' &&
|
||||||
firstArg.startsWith("Warning: It looks like you're using the wrong act()")
|
(firstArg.startsWith(
|
||||||
|
"Warning: It looks like you're using the wrong act()",
|
||||||
|
) ||
|
||||||
|
firstArg.startsWith(
|
||||||
|
'Warning: The current testing environment is not configured to support act',
|
||||||
|
) ||
|
||||||
|
firstArg.startsWith(
|
||||||
|
'Warning: You seem to have overlapping act() calls',
|
||||||
|
))
|
||||||
) {
|
) {
|
||||||
// DevTools intentionally wraps updates with acts from both DOM and test-renderer,
|
// DevTools intentionally wraps updates with acts from both DOM and test-renderer,
|
||||||
// since test updates are expected to impact both renderers.
|
// since test updates are expected to impact both renderers.
|
||||||
|
|
Loading…
Reference in New Issue