Prevent error boundary from masking a test error #11958
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This code in
ReactFiberScheduler
can suppress "unexpected console warning"Error
s thrown by our customtoWarnDev
matcher, so I've changed the matcher to report those Errors to Jest as failed assertions instead. This means that we won't halt as quickly as before, but we'll still fail within the bounds of theexpect().toWarnDev()
callback so it's probably okay.Before this change, the following test would unexpectedly pass:
After this change, it fails unless the warning is explicitly expected or the entire block is wrapped in an
expect(...).toThrow()
block.Note that the test would also have passed if we replaced
expect(ReactNoop.flush).toWarnDev([]);
above withReactNoop.flush();
because of the way our defaultconsole
"spy" queues Errors up to report in anafterEach
block.This PR also slightly improves the pretty printing message format in this case for when there are no remaining expected warnings or multiple ones. For example: