Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Allow .true() assertion to use an optional message #272

soundasleep opened this Issue · 4 comments

4 participants


Expected: expect(false)"message") should display "message".

Actual: It displays "AssertionError: expected false to be true".

Providing useful error messages is supported for other assertions (.a, .equal, .above etc), can this not also be supported for the core .true and .false assertions?


At the moment no properties (ok, true, false, null, undefined, exists, empty, arguments) take in a message. This is because these assertions are properties and not methods. You assert with expect(false) instead of expect(false).to.eql(true, 'message')

Would need true to become a method for this to be possible.

@keithamus keithamus referenced this issue in domenic/sinon-chai

Add lint friendly assertions #48


@keithamus I've been thinking about how this would be implemented while still supporting throw on property access when there may or may not be a function call at the end of the chain. I can't think of a way to look ahead in the chain.

// Throw on function call so that we can show message
expect(false)'Universal constants have broken down');

// Still support throwing on property access

// Support a message at the end of the chain with a property throw midway?
expect(false)'Universal constants have broken down');

Yeah, I'm inclined to agree. The only way I can think of is to have a runtime flag which disables the assertion in the getter and pushes it into the function.


Closing this as we had to revert #297. Unfortunately this doesn't look possible in the near to distant future for Chai.

@keithamus keithamus closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.