Skip to content
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

Fix gjs/gts bugs for ember-template-imports and ember-cli-babel #408

Merged

Conversation

vstefanovic97
Copy link
Contributor

@vstefanovic97 vstefanovic97 commented Mar 12, 2024

Changes

fix ember-cli-babel errors

  • Make sure that we always lookup our custom babel plugin via string lookup (This fixes ember-cli-babel parallelizam issues)
  • Added throwUnlessParallelizable: true in tests to prevent regressions

Fix ember-template-imports integration

  • Did custom path remapping when ember-template-imports used so that files get included in coverage report
  • Fixed gjs-gts-ignore-template-plugin not being executed in context of ember-template-imports (this was fixed by relying on inputSourceMaps) to get original file extension
  • Update test snapshot for regular app to also include gjs code coverage
  • Add test case for embroider + ember-template-imports
  • Updated readme with extra instructions from ember-template-imports


let counter = 0;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super minor, extra spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cah-brian-gantzler
Copy link

If you wanted to include the workflow from this issue #409 in this PR, I would be able to test these pending changes in my app.

@cah-brian-gantzler
Copy link

On testing I found that if I did a test without -s and filtered it so just a few test ran, it did produce coverage. However I was never able to reproduce it. So not adding -s does not seem to work.

When running test with -s, coverage was produced and it seemed to produce as expected for gjs/gts files. All the lines were marked correctly. All .js files, while having coverage, the marks were still off by one line.

@vstefanovic97
Copy link
Contributor Author

@cah-brian-gantzler so you are saying you already tested it on my changes and only problem you found right now is that for you it doesn't work w/o -s flag?

@vstefanovic97
Copy link
Contributor Author

@cah-brian-gantzler tbh I don't think any of my changes have anything to do with your -s flag bug.
Is the problem with -s flag still there on version2.0.3, if yes, then it is probably a totally different issue and should probably be a separate focus, as this PR is only to fix coverage for .gjs/.gts.

Also I it's hard for me to debug as I have no way of reproducing that, since on brand new classic/embroider apps it just works normal w/o -s

@cah-brian-gantzler
Copy link

@vstefanovic97 Im sorry I thought you were aware, yes, the problem with the -s is on 2.0.3 and unrelated to the .gjs/.gts issue. Since most people want to run coverage in CI, when they use this addon no coverage is produced at all so they think its not working.

Yes I was able to apply your branch to my code and it did produce the expected results for .gjs/.gts

@vstefanovic97
Copy link
Contributor Author

Ok then I guess we are good with my changes, thanks for the confirmation @cah-brian-gantzler!
Now we just need a review from @SergeAstapov

@@ -20,11 +20,12 @@ const gjsGtsTemplateIgnoreVisitor = {
const { node } = path;
let { callee } = node;

if (callee.name !== 'template') {
// if there is already a `template` varaible in scope content-tag will use `template1` local name and so on.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// if there is already a `template` varaible in scope content-tag will use `template1` local name and so on.
// if there is already a `template` variable in scope, content-tag will use `template1` local name and so on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type is fixed @SergeAstapov, also I made everything just one commit

template();
counter++;
console.log(counter);
}

export default template(\`
<template>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vstefanovic97 I may be wrong, but this change make this test not match it's title? like it says if template is not imported from "@ember/template-compiler" but with this change there is no @ember/template-compiler in play... or maybe test title needs to be updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeAstapov the template string is being passed to content-tag to be transpiled now
See here

But what this test is doing is making sure that this doesn't get an ignore comment added

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahha! Got it now! so we gonna rely on snapshots for this behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeAstapov
Copy link
Contributor

@RobbieTheWagner would you be able to give it a go if all looks good?

@vstefanovic97
Copy link
Contributor Author

Ping @RobbieTheWagner

Copy link
Collaborator

@RobbieTheWagner RobbieTheWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks so much for putting in this work 💪

@RobbieTheWagner RobbieTheWagner merged commit 9e01d23 into ember-cli-code-coverage:master Mar 20, 2024
1 check passed
@RobbieTheWagner
Copy link
Collaborator

@vstefanovic97 does this add template coverage or just fixes gjs/gts files?

@vstefanovic97
Copy link
Contributor Author

It just fixes gjs/gts files @RobbieTheWagner
There is no coverage for templates yet.
I haven't had time to look into that part tbh

@vstefanovic97
Copy link
Contributor Author

@RobbieTheWagner do you mind to create a patch release for this fix?

@RobbieTheWagner
Copy link
Collaborator

@RobbieTheWagner do you mind to create a patch release for this fix?

Just published 2.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants