-
-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation error #902
Comments
Short answer: Yes, you can attach a message. Documentation needs to be updated. Note that you can set a custom message in one of two ways, however the second way has a gotcha, so I recommend the first way: var myBreakfast = {sausage: 3, eggs: 2, toast: 2};
// First way: Put custom message as 2nd parameter to `expect`:
expect(myBreakfast, "NO BACON!!!").to.have.property("bacon");
expect(myBreakfast, "NOT ENOUGH TOAST!!!").to.have.property("toast", 5);
// Second way: Put custom message as 3rd parameter to `property`:
expect(myBreakfast).to.have.property("toast", 5, "NOT ENOUGH TOAST!!!");
expect(myBreakfast).to.have.property("bacon", undefined, "NO BACON!!!");
// Gotcha in last test: Asserts if `myBreakfast` has a property `bacon` that's equal to `undefined`... prolly not what is wanted Tested the above in both Chai 3.5 and the master branch. In both cases, the custom error was present. However, be aware that your test runner may modify the error message after catching it and prior to displaying it. For example, Mocha exhibits different behavior depending on whether or not the |
I'm not sure if this is related but I also had to include this line to get the message to show (and this is using the first way of custom message insertion:
|
Sounds like a separate issue. Do you have a public repo or standalone example I can look at? |
Just noting here that I'm updating the docs related to this. |
... so can I attach a message, or can't I? I seem to be having trouble getting a message to appear so that's probably a no?
The text was updated successfully, but these errors were encountered: