Adding descriptions to assertions?
See original GitHub issueWhen doing something like:
expect(something).to.exist
the output of a failure tends to be:
AssertionError: expected undefined to exist
This is not very helpful if there is trouble with the stack-trace, something you can run into e.g. when using Chai+Mocha+Velocity+Meteor.
Ideally, there’d be something like an as(label)
to add to the expectation:
expect(something).as('Foo').to.exist
which could then generate a more helpful output:
AssertionError: expected Foo to exist
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
How to Add Custom Descriptions to ScalaTest Assertion Failures
How to append or prepend a custom description to as ScalaTest assertion failure.
Read more >Add custom messages in assert? - c++ - Stack Overflow
A hack I've seen around is to use the && operator. Since a pointer "is true" if it's non-null, you can do the...
Read more >Testing with Spring Boot - Part 3 - YouTube
How to modify assertion description and how to assert exceptions - Testing with Spring Boot - Part 3 · Key moments. View all...
Read more >Using test assertion messages as comments - Swift by Sundell
One way to do that is of course to use good old fashioned comments — like in the following test, which verifies that...
Read more >Programming With Assertions - Oracle Help Center
For example, suppose you write a method to find the minimum element in an unsorted list, and you add an assertion to verify...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
aka
is a pretty nice name. Let’s see what others think.I’m surprised, because in nodejs, i’m used to do :
Why couldn’t it be useful for your case ?