mercredi 9 novembre 2016

How come Node.js Assert doesn't have a notOk() method?

I am learning about testing in Node.js using mocha and the assert module. assert has these types of methods:

assert.equal();
assert.deepEqual();
assert.deepStrict();
assert.strict();
assert.ok(); // Is the value true?

And then there are some opposites:

assert.notEqual();
assert.notDeepEqual();
assert.notDeepStrict();
assert.notStrict();

But there one missing... Why is there not a notOk() method for testing if the resulting value is false or not?

This got me thinking that maybe there is something fundamental I am missing about unit testing in general, in that maybe I should only ever be testing if values are true and never false...

For now, I have simply been doing this to test for falsey statements:

assert.ok(!myValue);

Is that how you are supposed to do it? Again, why isn't there just a notOk() method since all the other methods have a not version?

Aucun commentaire:

Enregistrer un commentaire