You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may or may not be related to #407, except that issue has a fix and I've tested with the fixed version of ember-cli-code-coverage to confirm the issue I'm reporting.
To make sure I had this addon set up correctly, I followed the documented steps for ember-cli-build.js in the readme:
sourceMaps are set to inline
babel plugin is set up
sourcemaps is enabled and set to JS extension
ember-template-imports inline_source_map config is enabled
Then, running the tests and checking the coverage output showed that when a component is a GTS file (with a GJS integration test file), the coverage % is lower than when it's converted back to separate TS/HBS files (with a JS integration test file).
One gts file I checked has a coverage output of {"lines":{"total":11,"covered":2,"skipped":0,"pct":18.18}.
The same file converted to separate ts/hbs files now has an output of {"lines":{"total":11,"covered":3,"skipped":0,"pct":27.27}.
Another one:
GTS - {"lines":{"total":5,"covered":1,"skipped":0,"pct":20}
TS - {"lines":{"total":5,"covered":2,"skipped":0,"pct":40}
While GTS files are in fact being output in coverage reports now, the numbers are not accurate, and that's artificially lowering test coverage compared to using classic Ember file formats. This likely also impacts GJS files, though I did not explicitly test it.
Tested in both v2.1.2 and v3.0.0 of ember-cli-code-coverage
Here's a snapshot of some other possibly relevant dependency versions:
Just to eliminate a theory, I tried keeping the component files as GTS but changing the test files back from GJS to normal JS (using the htmlbars inline precompile import), and the numbers did not change at all. It's only when abandoning GTS for the component that the coverage numbers rise again.
@elwayman02 could you maybe setup a repo with a minimal reproduction? Have one ts component and one gts component so I could debug and figure out why the coverages are diferent
I'll see if I can do that at some point (don't have time right now unfortunately), but one theory we just came up with is that it's because we're using ember-template-imports v3, whereas v4 has improved source map support. 🤔
I haven't tested side by side, but the examples I looked at were very basic. For example, one of the components I listed above (5 lines, 40% coverage, 20% coverage if GTS) had 3 actions, a tracked property, and a service injection. Something like this:
and the template, whether in HBS or format, was basically just a button that triggered makeVisible but was hidden if isVisible, another button that triggered showBar with fn to pass a different string, and a component which was rendered if isVisible and passed onShowBar as an argument.
Activity
elwayman02 commentedon Jul 24, 2024
@vstefanovic97 since you were able to fix the missing coverage in the first place, do you have any insight into why this might be happening?
elwayman02 commentedon Jul 24, 2024
Just to eliminate a theory, I tried keeping the component files as GTS but changing the test files back from GJS to normal JS (using the htmlbars inline precompile import), and the numbers did not change at all. It's only when abandoning GTS for the component that the coverage numbers rise again.
vstefanovic97 commentedon Jul 24, 2024
@elwayman02 could you maybe setup a repo with a minimal reproduction? Have one ts component and one gts component so I could debug and figure out why the coverages are diferent
elwayman02 commentedon Jul 24, 2024
I'll see if I can do that at some point (don't have time right now unfortunately), but one theory we just came up with is that it's because we're using ember-template-imports v3, whereas v4 has improved source map support. 🤔
vstefanovic97 commentedon Jul 24, 2024
@elwayman02 can you give hint where is this extra covered line in the ts files?
elwayman02 commentedon Jul 24, 2024
I haven't tested side by side, but the examples I looked at were very basic. For example, one of the components I listed above (5 lines, 40% coverage, 20% coverage if GTS) had 3 actions, a tracked property, and a service injection. Something like this:
and the template, whether in HBS or format, was basically just a button that triggered
makeVisiblebut was hidden ifisVisible, another button that triggeredshowBarwith fn to pass a different string, and a component which was rendered ifisVisibleand passedonShowBaras an argument.