Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow DeveloperError Jasmine matchers to accept regex for messages #12338

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jjspace
Copy link
Contributor

@jjspace jjspace commented Nov 25, 2024

Description

  • 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
  • I have performed a self-review of my code

Copy link

Thank you for the pull request, @jjspace!

✅ We can confirm we have a CLA on file for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant