-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[expect]: add empty string check to toThrow matcher #6836
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What about fixing the pattern instead? This will give weird results for falsey values outside of empty strings (such as |
@SimenB I've just updated it to default to |
Not sure why the tests are failing now! I'd say something maybe depends on providing empty strings to the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@mattphillips it doesn't fail locally? |
@SimenB seems like the failing tests are:
What is weird is that they are failing for me locally on master too (I did a clean clone/install/test)
|
@mattphillips that fails for me locally as well, not sure why.. However, the only test failing on CI is |
@SimenB I've just spent a chunk of time investigating why this test is failing and couldn't figure it out, so many moving parts 🤣 I've instead moved the check to the matcher itself as we know for sure this is the behaviour we want - let me know what you think? |
Expected the function to throw an error matching: | ||
<green>\\"\\"</> | ||
Instead, it threw: | ||
<red> Error</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this text include 'apple'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file defines a custom error with a fixed message for the snapshot - I’ve just reused that which is why it doesn’t say apple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems silly, doesn't it? Is the error inconsistent if we drop the fixed message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it does a bit! I’ll give it a go and see what happens, maybe it was giving inconsistent line numbers 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I just noticed this comment above the custom error/stack:
Custom Error class because node versions have different stack trace strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it still valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, toThrowErrorMatchingSnapshot
only snapshots the message
, not stack
@mattphillips what's the status here? To fix your failing test locally, run |
Not needed see #6805 (comment) |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Add a truthy check of the given
value
when performingtoThrowMatchingStringOrRegexp
in thetoThrow
matcher.@SimenB @thymikee I'm not sure if you want to solve this another way but this seemed this simplest, what do you guys think?
Fixes #6805
Test plan
Added unit tests for empty string.