Open WORMSS opened 1 year ago
true
is an alias for ok
, which has no strict/loose variants - it's just checking truthiness/falsiness. If you want exact, use t.equal(x, true)
.
Yes, I have since read the documentation, I believe it being an alias is a mistake and should be stopped. Yes, I did use equals, as a hacky work around, rather than a solution to the inconsistency in the api.
ok()
I believe is acceptable to be loose.. true()
I believe is NOT acceptable to be loose, and should no longer be an alias of ok()
but it's own method to test for true
I can certainly see your argument.
This behavior has been part of tape since its inception - added in https://github.com/ljharb/tape/commit/7948e2ee439135efee86ea0b7ce24c9deea4b018, modeled after https://www.npmjs.com/package/tap, and is how tap continues to behave.
It's not worth a breaking change just for something like this, and i think mimicking tap is a pretty important priority. Can you try making your argument there as well?
Funny thing, I'm looking through their docs.. and .true()
and .false()
don't actually appear within their asserts
list.
I literally had to go into their code to even find that these aliases exist at all.
Indeed, aliases don't seem documented at all, but they've survived many major versions none the less.
I pretty much summed up this thread here.
https://github.com/tapjs/node-tap/issues/861
Just for the record.
Seems reasonable to remove those aliases in the next semver-major, but I'm not sure when that will ever occur :-)
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..t.true("false")
should NOT pass.. That is just crazy.Especially when you have
t.equals()
andt.looseEquals()
Sot.equals()
is strict by default.. butt.true()
is loose by default..There just doesn't seem to be consistency in the api.