-
Notifications
You must be signed in to change notification settings - Fork 4
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
Coverage and line counting issues. #39
Comments
Thanks for highlighting all this! I have struggled with the You may find it handy to include a list of locations hit in your metrics for lines (e.g. line 4 hit locations 5 and 7) – that will give you insight into some of the "magic". My guess for the magic is that adana is injecting and counting its phantom "else" branch there and both are being counted for that line. I don't know that for sure, but that's my guess. I'm not sure what to do about certain expressions – I feel like an expression statement (in general) should cover all lines in that statement (e.g. in yours the line 19 statement should cascade through to line 32). I don't know if I want to add coverage for every single operator? Maybe? It could be done certainly (and at present there is no markers added for operators of any kind). It would enhance the accuracy of statements like: const x =
foo() +
bar() + // if this line throws an error then baz won't be covered
baz(); Also you should totally move your html formatter repo over to the org if you'd like! I'll delete the shell one I have and yours can replace it. 😄 |
I had never written a babel plugin before, so in order to learn I started a rewrite of adana transformer from scratch and came up with a version that seems to work well for the app we're working on here. Below is a screenshot of the code coverage with my version of adana. It's quite similar to the report that we get from Istanbul, but the big plus is that the branch count is better (Istanbul reports 20 branches because it is based on the transpiled results). I'm also adding an example that has classes, I'll clean up the code and upload it so that you can take a look. |
Here it is: babel-plugin-transform-adana-alt. I really should have done it as a fork, but at the time I thought I was just going to play around... I will prettify it and make a proper MR if we decide to use it. Notable changes:
Also there's Tape for unit tests, but I can switch to Mocha if you think it's better. And for linting I used eslint-config-meetic because we're actively using it in our projects (and frankly I'm not really a fan of metalab config, because it changes too much from one version to another, has a dependency on react plugin and v2 wants me to use function expressions for some reason). And I really want to change the name "prelude.js" to something else... have no ideas yet. |
Phew lot to go over 😄
|
My recommendation is to (in priority order):
Additionally at some point (if you want):
Thanks again for all the hard work and interest in this! |
Also as a total aside regarding tags: it might be interesting to write a function in |
Thanks for explanations! I the user-defined tag idea is great. (Side note regarding tags: I've made a PR to adana-analyze because it threw an error when I attempted to instrument a class constructor). There are some ideas for a more interesting highlighting of the code and functionality in the html reporter (like ranges and drill-down on click or mouseover), but there's just not enough time to do it all. I'll get to it eventually. Let's stick to Mocha for the time being. |
I'm continuing working on the HTML reporter and starting to get visual representation of our code coverage. There are some issues, mostly due to the fact that the
lines
function in adana-analyze reports all lines betweenloc.start
andloc.end
as covered with coverage count of the parent node. This not only results in empty lines having coverage count, but also in the fact that empty lines have higher count than their neighboring lines with statements and the such (compare lines 18 and 19).So, I changed the line counting loop to only include
loc.start
and useMath.max
on counts. This solves two issues:Below is the screenshot of the result. It's only a little bit better.
The text was updated successfully, but these errors were encountered: