The builtin .toThrowError() and .toBeRejectedWithError() matchers accept a string or regex for the expected result. If a regex is provided it will test against that instead of an exact match. This is useful to allow a little flexibility, especially for errors with dynamic parts
This PR adds the regex functionality to .toThrowDeveloperError() and .toBeRejectedWithDeveloperError()
.toThrowDeveloperError() didn't even allow for an expected string message so this also now provides that functionality
There were actually 3 tests trying to use this functionality with incorrect error messages which may have caused dev confusion in the future
Issue number and link
No issue
Testing plan
Do a project wide search for any .toThrowDeveloperError() or .toBeRejectedWithDeveloperError() call and focus that tests
Verify the tests still pass with no modifications
Test strings as the expected message, these must match the full string exactly
Test regex as the expected message, these can be a portion of the message or anything that will test as positive against the actual message
Author checklist
[ ] I have submitted a Contributor License Agreement
[ ] I have added my name to CONTRIBUTORS.md
[ ] I have updated CHANGES.md with a short summary of my change
[ ] I have added or updated unit tests to ensure consistent code coverage
[ ] I have updated the inline documentation, and included code examples where relevant
Description
.toThrowError()
and.toBeRejectedWithError()
matchers accept a string or regex for the expected result. If a regex is provided it will test against that instead of an exact match. This is useful to allow a little flexibility, especially for errors with dynamic parts.toThrowDeveloperError()
and.toBeRejectedWithDeveloperError()
.toThrowDeveloperError()
didn't even allow for an expected string message so this also now provides that functionalityIssue number and link
No issue
Testing plan
.toThrowDeveloperError()
or.toBeRejectedWithDeveloperError()
call and focus that testsAuthor checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change