expect
expect copied to clipboard
`expect(value, message)` Custom error message
I like the Chai's expect and a feature that is useful is the custom error message, because this allows to tag some test, specify the error in the test, or just leave a note.
I can make the implementation, only I need to know if you accept this idea. The implementation will put the custom message before the generated error.
Examples:
expect(mime("rtf"), "Rich Text Format").toEqual("application/rtf")
// > error: Rich Text Format: AssertionError: expect...
expect(var.some, "The generator puts this property").toEqual(2)
// > error: The generator puts this property: AssertionError: expect...
From their [ChaiJS] docs:
.a accepts an optional msg argument which is a custom error message to show when the assertion fails. The message can also be given as the second argument to expect.
expect(1).to.be.a('string', 'nooo why fail??'); expect(1, 'nooo why fail??').to.be.a('string');
I'm waiting for your answer. Thank you.