-
Notifications
You must be signed in to change notification settings - Fork 176
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
(Possible) Bug in Lab Coverage Checker ? #401
Comments
Having a similar issue. I switched from supertest/mocha+chai/istanbul and 100% coverage to server.inject/lab/lab and 99% without changing any code other than moving some tests around. Thinking the coverage is having issues with complex booleans? https://coveralls.io/builds/3021647/source?filename=src%2Froute_builder.js So getting knocked on the |
@dbashford thanks for your quick reply and for confirming I'm not going insane! The What did you end up doing to re-gain your 100% test coverage? Is this a "Bug" or a "Feature"...? |
@nelsonic is there a test where the if block is not executed? |
Is it possible the file is loaded and executed before lab does its thing? |
@nelsonic does the html report provide any additional clues, perhaps the conditional isn't needed? |
…only required once test is running as suggested hapijs/lab#401 (comment)
I ran into an issue similar to this, perhaps this exact issue. It happens to me with lab 10.3.0 (no other dependencies needed). The problem, I believe, is when an if conditional is checked for only true or false, when there is no else. In that case, we don't expect to have to also test the false condition, because there is no false path. So assuming the following code:
Then assuming this code is tested with either myCondition or !myCondition, but not both, lab will report that the myCondition is not covered. I find this to be confusing, especially considering myCondition has been evaluated. See the attached files for a very simple repro case. To run the test cases: |
@mbargiel That's the expected behavior, the line is covered but if it's always true or always false what's the point of having it at all ? |
While writing this feedback, I figured as much. Maybe the problem is how this information is reported, but I have no solution to offer, since the only output is basically a list of line numbers. I guess lab users "just have to know". In my case, I may have to disable coverage for that if (because the if is always true in tests, and sometimes false outside of tests). |
@mbargiel this is now fixed in the html reporter, which shows parts of a line that can be removed |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
Hi @geek
Hope your day is going well.
I'm in the process of writing a (Fully Tested) Hapi.js + Socket.io + Redis Pub/Sub Example/Tutorial app... see: https://github.com/dwyl/hapi-socketio-redis-chat-example/
But, sadly I'm unable to get Lab code coverage checker to cooperate...
Lab coverage is convinced that a few lines of my code are not being covered by my tests, when they clearly are being executed!!
I don't understand ... 😢
If you (or anyone else in the illustrious list of contributors) can give me some insight I'd be super grateful!
Git Commit: dwyl/hapi-socketio-redis-chat-example@a8722bb
The text was updated successfully, but these errors were encountered: