-
-
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
[readme] improve t.throws
documentation
#542
Conversation
* Added usage example for when expected parameter is a validation object. See #540.
Codecov Report
@@ Coverage Diff @@
## master #542 +/- ##
=======================================
Coverage 74.15% 74.15%
=======================================
Files 19 19
Lines 766 766
Branches 146 146
=======================================
Hits 568 568
Misses 198 198 Continue to review full report at Codecov.
|
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.
looks great!
Great, thanks for allowing me to help :-) Again, if there are issues with that documentation, or it needs modification/augmentation, feel free to ping me and I'll be happy to take a look. |
had fixed in the latest version. Sorry
銀桑 <[email protected]> 于2021年2月26日周五 下午10:53写道:
… Wrong case in doc.
I run the second and get passed.
const tape = require('tape')
tape('test for error', (t) => {
t.plan(1)
const err = new TypeError("Wrong value");
err.code = 404;
err.check = "true";
// Failing test.
t.throws(
() => {
throw err;
},
{
code: 404,
check: true // This is not deeply strictly equal to err.check.
},
"Test message."
);
})
result is
1..1
# tests 1
# pass 1
# ok
I tried to debug in source code, this line
<https://github.com/substack/tape/blob/master/lib/test.js#L680> is wrong.
this._assert(typeof fn === 'function' && passed, {
message: defined(msg, 'should throw'),
operator: 'throws',
actual: caught && caught.error,
expected: expected,
// while caught is an error object, !passed return false, no error will be throw.
error: !passed && caught && caught.error,
extra: extra
});
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#542 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC6M2UEOR7K6VNDSABUHJDLTA6YWLANCNFSM4WTMZOUA>
.
|
YES, well done 😃 I was just posting here that I remember having a similar issue when I was originally testing that particular case--every test kept passing, even those that should fail. Then I realized my version of tape was 4.14.4. When I updated to v5+, the issue went away. So you're not the only one it fooled. Actually, maybe I should add a note to the README warning others of that. |
I don’t think we need a note in the readme for something that applies to every software project ever written - “check the docs that match the version you’re using”. |
Addresses #540.