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.

how can I know which assertion failed ?

See original GitHub issue

Hi guys, don’t know if it’s a Chai question / Mocha, but I am facing a very basic issue that I feel like i’m missing something.

Some of my tests have more than a few assertions and when some of them fail all I get is something like AssertionError: expected true to be false.

Is there any way to know which assertion failed ? Line number / stack trace perhaps ?

I know I can add a text description to each assertion but I don’t want to clutter my test files with unnecessary text just to mark which assertion failed when a line number would be sufficient.

Right now I am just commenting out assertion and re-running tests just to find the faulty one. I feel stupid when I do that…

Thanks 👍

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mderazoncommented, Apr 13, 2015

Thanks

I actually do see that in some cases Mocha gives me a line number (greyed out below the assertion). For example when running the assertion

expect(res.body.code).to.equal('something');

I get

AssertionError: expected 'success' to equal 'something'
      + expected - actual

      +"something"
      -"success"

      at Context.<anonymous> (order-test.js:239:30)

But in other cases when I run for example the assertion

expect(res.body.data.user.can_buy).to.be.true;

I simply get

1) should charge successfully


  0 passing (8s)
  1 failing

  1) charge should charge successfully:
     AssertionError: expected false to be true
0reactions
meebercommented, Jun 9, 2016

Seems this has been resolved but let us know if otherwise.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Phpunit which assertion failed? - Stack Overflow
The tests are below. My question is, how am I supposed to know which assertion failed? Do I need to add messages to...
Read more >
How to View Multiple JUnit Assertion Errors in One Test ...
Learn an easy solution to view all of the JUnit Assertion errors in one test execution from the test automation professionals at tapQA!...
Read more >
C/C++ Assertions - Visual Studio (Windows) - Microsoft Learn
The assertion message appears in both the Output window and the Assertion Failed dialog box. You can copy the assertion message from the...
Read more >
JUnit 5 Assertions: Verifying Test Results | Code With Arho
Learn the basic assertion methods, error message customization and ... If the assertion failed, we would see both the expected and actual ...
Read more >
Assert Function (The GNU Awk User's Guide)
When writing large programs, it is often useful to know that a condition or set ... If an assertion fails, the assert() macro...
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