-
-
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
t.throws() expected and msg parameters don't seem to behave as they are described. #540
Comments
Looking at the code, if It seems like it might be helpful here to fail if Additionally, the docs need updating; |
OK thanks for all that--it is helpful.
OK I understand now, and can confirm this behavior--thanks for that explanation. But is that typical behavior in JS? That behavior wasn't entirely obvious to me from reading the documentation. I guess I could have looked at the source code. Just my two cents, but adding a sentence to the
I don't understand--what exactly are you referencing with
OK noted, thanks. |
It's typical behavior in a lot of older APIs that allow you to omit "not the last" parameter. I'd be happy to review a PR that improves the docs.
|
OK got it--thanks for the explanation.
OK noted. I would very much like edit the README instructions to indicate this behavior with
So is that to say that |
Yes, that’s right. It’s one that is almost never used except by custom assertions, altho you might do something like this: t.throws(fn, TypeError, msg, { skip: true }); |
OK thanks for that. Understood that
I'll omit any mention of |
That sounds awesome, thank you! |
OK sounds good. I may need a few days though. In the meantime, do you want to close this issue? You've answered my original issue. When I create the pull request, maybe I can reference this issue (and vice versa?). |
I’m fine leaving it open, and closing it via your PR. |
OK cool. Sorry, needing a few more days on this--something came up at work. |
Hi Jordan, I'm back, and want to add that validation object example to the
FYI I borrowed this example from the Node documentation page on assert.throws(). |
https://github.com/substack/tape/blob/master/lib/test.js#L617-L630 is the code that's supposed to be handling it. In other words, it should be returning false if the code values aren't deeply strictly equal. Perhaps your PR could include test cases? If they fail, we've got a bug to fix :-) |
OK thanks for the link to that code--it should be helpful here. Let me run my example test a few times while stepping through this code with a debugger, to see if I can narrow down the issue (if any). If I can do that, what do you want as the next step? How about I create a new issue here in GitHub, describe the problem I'm experiencing, then open a PR referencing the issue so we can discuss? Or would you rather me to skip the issue creation, and simply open a PR? And for the time being, do you want me to perhaps remove the validation object information from the |
Up to you; no need for an issue first if you’re not doing anything controversial :-) The unpublished readme shouldn’t confuse anyone; let’s get it fixed instead. |
OK gotcha--no issue, just a PR. Let me try to do some debugging now. |
OK I had a better look and believe I see the issue--good old user error :-) In my testing, I was using Tape v4.13, and it appears that the code you highlighted was added after that version. Once I tested with the latest version of Tape, I can indeed confirm the expected behavior. Sorry for the confustion there! Let me add the example to the README now and submit a PR. Stand by... |
Hello. I am a little confused by the documentation for t.throws(), as it seems to be discrepant in two ways with the behavior I experience:
The documentation says that the
expected
parameter, if present, must be a RegExp or Function. But when I pass in a string, and execute a test, the test seems to complete without issue (see below for code). Furthermore, the string passed as theexpected
parameter is printed to the console, seemingly as the test description. Nor does theexpected
string match the string representation of the exception (as described in the documentation). Here is a screenshot of a passing test--something similar occurs for a failing test. Why is that? What am I misunderstanding?The documentation mentions that the third parameter--
msg
--is an optional description of the assertion. So when/where exactly is this string used? I’ve executed two tests—one passing and one failing (see below for code). In neither case is themsg
parameter printed to the console (see pass screenshot here; see fail screenshot here).My passing test. To change it to a failing test, comment out the
throw
line.Thanks in advance.
The text was updated successfully, but these errors were encountered: