Fix no coverage reported for files in app directory of in-repo addons#342
Fix no coverage reported for files in app directory of in-repo addons#342robinborst95 wants to merge 2 commits intoember-cli-code-coverage:masterfrom
Conversation
ba419db to
8598190
Compare
8598190 to
7a8532d
Compare
7a8532d to
abdd695
Compare
|
@kategengler @rwjblue I haven't added support for in-repo addons with a path like |
|
@thoov I see that this PR might help resolve the issue I've tried to fix here, is that what you meant it for? If it indeed does fix our issues, then I do think that it's not trivial that such a customization is needed when it can be detected by this addon as well (which was what I was striving for). Besides, if the @kategengler @rwjblue any thoughts on this? @rmachielse and I (and the other developers in our team) are eager to start using the beta version to speed up our development process, but this issue is a blocker for us, so any help to get this issue fixed would be appreciated 🙏 |
In this PR I first added a failing test to confirm this issue. Then I tried diving into the code to see if I could fix it, which I eventually could. I've tested this with our codebase and all our files showed up correctly again 🙌 I'm not too sure if this is the right way to fix it, so I'm open for suggestions.
First I generated the changes in the snapshot by moving the added util to. Edit: it did require a small tweak, as I was missing the two re-exports that had no effect on the coverage in the test. The rest of the initial failing test was working as I expected it to.addonand re-exporting it inapp. Then I moved it back fromaddontoappand manually adapted the snapshot. So, I expect this test to pass when the issue is fixed, and otherwise it will probably require a little tweak to get it workingIf I understand correctly, the coverage is reported for files like
app-namespace/components/...,in-repo-addon/components/..., paths that are then converted intoapp/componentsandlib/in-repo-addon/addon/componentsrespectively (assuming that the in-repo addon is inlib/in-repo-addon). For theappfiles in those addons though, the initial path is alsoapp-namespace/components/..., so then there is no trivial mapping to the addon'sappdirectory possible. In the end I got it working by checking if the file exists in the app-namespace'sapp, and if not, it has to come from an addon. It can still come from another addon though, so then I checked per in-repo addon whether the file exists there or not. If it does exist, we know that the path should be changed to the addon's path.This approach does work for our codebase and in the tests and I also found something else it covers now as well. In the
in-repo-addontest themy-app-with-in-repo-addon/lib/my-in-repo-addon/app/services/my-service.jsfile isn't covered because ofapp/services/my-service.js, so that's a nice bonus I'd say :).