how can I know which assertion failed ?
See original GitHub issueHi 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:
- Created 8 years ago
- Comments:12 (5 by maintainers)
Top 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 >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
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
I get
But in other cases when I run for example the assertion
I simply get
Seems this has been resolved but let us know if otherwise.