Binding assertion methods?
mindplay-dk opened this issue · comments
I intuitively want write tests like this:
test("something", ({ ok, equal }) => {
ok(true, "stuff");
equal(1, 2);
});
Unfortunately, the functions on the t
object use unbounded this
, so this leads to weird errors.
I'll admit, I have a general aversion to this
and consider it bad practice - in part because of issues like this.
I know the README prescribes a pattern where you qualify these calls at every call site - but the name t
just doesn't make any sense to me, and I struggle to come up with a meaningful name... I usually end up doing this:
test("something", is => {
is.ok(true, "stuff");
is.equal(1, 2);
});
At least this has some sibilance of semantic, but... is.throws
? meeeh. 🤨
I realize it's technically a breaking change, but could we maybe avoid this
and bind the assertion functions?
It looks like these are internally closures anyhow, so maybe it's not even a breaking change?
I hope this doesn't seem like a nitpick. I mean, it might be. I've been using zora for a long time, and this has always bugged me.
it seems legit. Less this
, less problems. I'll try to have a look
this should be fixed