moll / js-must

An assertion library for JavaScript and Node.js with a friendly BDD syntax (awesome.must.be.true()). It ships with many expressive matchers and is test runner and framework agnostic. Follows RFC 2119 with its use of MUST. Good stuff and well tested.
Other
336 stars 35 forks source link

Improve error message for length assertion #73

Closed herintsoa-hasina closed 3 years ago

herintsoa-hasina commented 6 years ago

Hello guys,

I like very much the js-must project as a test tool in my own project. When searching in the source code, I was interested to make the length assert error message more expressive. I modified the Must.prototype.length implementation to improve the ouput of the error message assertion. In fact, it will be more interesting to show the difference between the expected and the actual length when the assertion fails.

For example, [2,'a'].must.have.length(3) should return this output

AssertionError: [2,"a"] must have length of 3
+ expected - actual
-2
+3

Or"hello".must.have.length(3) with the output

AssertionError: "hello" must have length of 3
+ expected - actual
-5
+3
moll commented 3 years ago

Hey! Sorry for the belated reply. That seemed like a reasonable suggestion. Thank you! I've merged it in and will release a new version shortly.

moll commented 3 years ago

Btw, are you the same person as https://github.com/mrHerintsoaHasina?

herintsoa-hasina commented 3 years ago

Yes I am

Le lun. 2 nov. 2020 à 13:37, Andri Möll notifications@github.com a écrit :

Btw, are you the same person as https://github.com/mrHerintsoaHasina?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/moll/js-must/pull/73#issuecomment-720446177, or unsubscribe https://github.com/notifications/unsubscribe-auth/AISV5AYPHFXCCNWG7SCFAFLSN2RZJANCNFSM4EUBFVLA .