-
Notifications
You must be signed in to change notification settings - Fork 208
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
[Feature] Custom message #18
Comments
+1 for the This is actually somewhat of a pain point for me in terms of not being able to convey enough useful information when tests fail while in a loop — usually I note the index or item being iterated over in my custom failure messages. It makes reproducing it take a bit longer as I have to either add console logging or step through it with a debugger to find the point of failure. |
How about
|
Seems confusing to me. It makes me think of logical OR, such that it would be doing the following:
|
|
My preference is for the message at the end, as a parameter to the final chained flag. |
Agreed, at the end IF it can't be chained as a separate |
Ok in that case we just simply need to add it as a parameter to all the methods of the |
Would love this too, and as an extra parameter to the assertion method makes sense to me too. Not sure how you would be able to chain after the assertion -- the assertion would fail, but it wouldn't be able to throw right away since it doesn't know the message yet. When would it throw then? On |
+1 |
1 similar comment
+1 |
+1
|
@guille, I might be able to whip up a PR to add an extra message param to all assertion methods in the next couple of weeks. Would you like me to? |
I'm down. And docs |
Thanks! |
+1 - Right now if you check for example a jquery object for being empty, you get this giant bomb in your console window. This would so be the right solve for that. I mean we're throwing errors so having an error msg makes sense |
+1 |
this was brought up a year go, any progress on anything? I wouldn't even care if i had to do
or something, I don't care if it even makes sense, i just want some sort of functionality to add information to failing tests. |
+1 |
Sorry, I never got around to this. FYI though that the version of http://chaijs.com/guide/styles/#expect
The only thing I don't like about Chai's Edit: that has been fixed in recent versions of Chai — those things can be called as methods now! |
Chai's a great tool, but it doesn't work in IE 8—that's why I use expect.js. :-) |
The problem I see with the approach of adding a // when equal() is called, if the assertion fails it will throw an error
// immediately, meaning that msg() will never evaluate
expect(43).to.equal(42).msg('43 is not the answer'); That said, the syntax is rather nice. It seems like adding a message parameter to all of the assertion methods would work well, and falls in line with other assertion toolkits. |
👍 |
BTW, if anyone out there is tired of waiting for an official implementation (it has been 2+ years ...), this feature is pretty easy to add yourself. Just ... !) Run the following code anywhere after you load expect.js (but before running your tests):
Hope that helps someone. P.S. expect.js developers, I'd be happy to submit a pull request if you'd like to add this code officially. |
👍 |
@rauchg Any news here? It would be great feature! |
@aseemk 👍 Any news? |
@guileen: I moved to Chai, which already supports this. See #18 (comment). =) |
+1 - we really need it. we have multiple expects in a single |
FYI - we found we need to tweak the code above. this is our version.
However this is not a pull request level code, but it works. for example |
Would be real nice 👍 |
@guy-mograbi-at-gigaspaces, doesn't work with Meanwhile you can use:
|
@rafis try: |
👍 for |
+10 Since +1 not work well |
👍 |
Is this still not resolved at all? There's no way to be more specific in your error message about what specifically failed? |
Would it be possible get a facility for adding a custom message to errors? Maybe an extra parameter somewhere, or an extra chained flag:
The text was updated successfully, but these errors were encountered: