-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
Document that expected must be a RegExp #101
Conversation
You get silent false positives if you use e.g. TypeError instead of /TypeError/.
Document that expected must be a RegExp
Should it also accept a string? |
I don't think so. Maybe it should accept constructors, but strings are not that great, especially given the message string adjacent to it in the parameter list. |
I'm currently using this by passing in Using |
Look at the source code. /^TypeError$/ of course fails because the message is nonempty. From: Jordan Harbandmailto:[email protected] I'm currently using this by passing in TypeError, the constructor function. When I change it to use /^TypeError$/, I get a failure with expected: '/^TypeError$/', actual: { message: '…' } Using /TypeError/ also passes, but that seems like it's abusing string coercion. Is this argument not expected to be the Error constructor function? — |
So it seems like @substack would you be willing to accept a PR that has an additional check for if |
Seems fine to me. Overloading is an anti pattern. On Sep 17, 2014, at 9:31, "Jordan Harband" <[email protected]mailto:[email protected]> wrote: So it seems like expected is totally unused unless it's a regex - that doesn't seem very useful to me :-/ @substackhttps://github.com/substack would you be willing to accept a PR that has an additional check for if expected is a function, and another if it's an Error object? Reply to this email directly or view it on GitHubhttps://github.com//pull/101#issuecomment-55921246. |
@ljharb just open a PR. Making |
You get silent false positives if you use e.g. TypeError instead of /TypeError/.