I can't seem to set a custom message for the following commands:
expect.element(#element).text.to.equal
and
expect.element(#element).text.to.match
I've tried using the assert.containsText command but it doesn't support regex as far as I can see and the normal getText doesn't support custom messages. Not sure what I should be using or how.
Think this is related to the previous feature request "Feature Request: Messages for expect #507" where custom message support is only added for the css, attribute and type expect selectors.
Ok so for now I'll use this:
this.browser.getText('#element'), function(result) {
var regex = new RegExp(expression, "i");
this.assert.equal(true, regex.test(result.value), 'custom message');
});
Would've been nice if I can just use the expect namespace
Hi @louiscbotha!
To answer your question on Issue #507, I implemented the custom messages only for the assertions that are methods, not properties. This is similar to how chai does it: https://github.com/chaijs/chai/issues/118.
I might try to implement it so that it's part of the expect interface!
I see attribute and css can have custom messages. Can this same functionality be implemented in all expect assertions ?
How it's looking now? :-)
How it's looking now? :-)
I found this issue because Nightwatch won't print custom message, so seems it still doesn't work.
my assertion looks like
.expect.element('CSSselector').text.to.equal('Text to check', 'Custom message');
I'm using nightwatch v1.0.18
Most helpful comment
I see attribute and css can have custom messages. Can this same functionality be implemented in all expect assertions ?