jcoglan / jstest

The cross-platform JavaScript test framework
38 stars 3 forks source link

counting assertions doesn't work with chai #6

Open eurekaa opened 10 years ago

eurekaa commented 10 years ago

Hi, i'm using jstest with chai but if i write jstest.Test.ASSERTION_ERRORS.push(chai.AssertionError) i can't even get the number of assertions, which remains to 0, it just count the errors. How can i solve? Thanks.

jcoglan commented 10 years ago

You can't; the assertion count only catches assertions made with the built-in jstest assertions. Counting other assertion library calls would require intercepting them somehow, probably by monkey-patching the target library.

eurekaa commented 10 years ago

It would be interesting to add expect and should libraries too, is it possible? Maybe i can help.

jcoglan commented 10 years ago

The point I was making is that making jstest count assertions from other libraries would necessarily involve monkey-patching those libraries, introducing coupling and possible breakage that doesn't sit comfortably with me. There is also a problem with the definition of 'one assertion' which can vary, e.g. jstest considers mock expectations as assertions since those are frequently the only kind of check in tests that they appear in.