-
-
Notifications
You must be signed in to change notification settings - Fork 269
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.true()
and t.false()
should be exact and not aliases of the loose t.ok()
and t.notOk()
#861
Comments
These aliases are inherited from other assertion libraries, where In the next major version, they'll be removed. In the current one, they're already printing deprecation warnings. So, good news! You'll get your wish! |
Dear lord, how deep does these aliases go? Do you know which libraries the aliases were inherited from? |
The main things I copied from were node's original assert module, CPAN's Test::More, and jspec. Idk what those things were modeled on. Just seemed easiest at the time to let people use whatever names for assertions that they wanted. Probably some of the patterns predate JavaScript, idk. TAP itself goes back as far as Perl v1, in 1988, though there've been quite a few changes over the years. It's actually kind of weird that |
I feel fine with Oh well.. |
Right, but in the TAP protocol, "ok" and "not ok" are "primitives". |
I know you have
t.ok(true);
t.ok("moose");
and that is absolutely fine to be loose.but I was wracking my brain for ages trying to work out why tests were passing, but in real environment, things were breaking..
Eventually I found why my tests were not acting like I was expecting.
t.true("false")
should NOT pass..That is just crazy.
Especially when you have
t.equals()
andt.looseEquals()
So
t.equals()
is strict by default.. butt.true()
is loose by default..There just doesn't seem to be consistency in the api.
I don't actually see
t.true()
at all but I spotted it in the code as being an alias oft.ok()
and I believe it being an alias is a mistake and should be stopped.I did a hacky work around, and used
t.equal(result, true)
but thought best to get a solution to bring consistency to the api.Just to be clear
t.ok()
I believe is acceptable to be loose..t.true()
I believe is NOT acceptable to be loose, and should no longer be an alias oft.ok()
but it's own method to test for the exact value oftrue
(and same for the t.false() assert)
If the name was
t.ok()
andt.truthy()
I wouldn't have been so confused for so long.The text was updated successfully, but these errors were encountered: