question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding descriptions to assertions?

See original GitHub issue

When 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:closed
  • Created 9 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
keithamuscommented, Aug 29, 2017

aka is a pretty nice name. Let’s see what others think.

3reactions
abenhamdinecommented, Sep 21, 2015

I’m surprised, because in nodejs, i’m used to do :

 expect(something, 'Foo').to.be.a('string');

Why couldn’t it be useful for your case ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found