8000 feat(test): Add code coverage for karma runs by delasteve · Pull Request #895 · angular/angular-cli · GitHub
[go: up one dir, main page]

Skip to content

feat(test): Add code coverage for karma runs #895

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

Closed

Conversation

delasteve
Copy link
Contributor

No description provided.

@delasteve delasteve closed this May 23, 2016
@delasteve delasteve reopened this May 23, 2016
@delasteve delasteve force-pushed the feature/add-code-coverage branch from 39f3d3a to c9f43fa Compare May 23, 2016 17:46
@delasteve
Copy link
Contributor Author

I think my accidental closing of the issue caused this to not build on AppVeyor. Is there a way rerun the build manually?

"karma-jasmine": "^0.3.8",
"karma-remap-istanbul": "git+https://github.com/marines/karma-remap-istanbul.git#patch-1",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sorry but I can't allow every CLI dependencies to be reliant on a ref on someone's GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. So, there are two options:

  1. We wait for the dev to implement the PR for karma-remap-istanbul
  2. We/I/Someone creates karma-remap-istanbul2 with the fix.

Suggestions?

@delasteve delasteve force-pushed the feature/add-code-coverage branch from c9f43fa to 79470a3 Compare May 24, 2016 20:18
@delasteve
Copy link
Contributor Author

@hansl, I got in contact with @marcules, the maintainer for karma-remap-istanbul and was able to release a new version (0.0.6). This should take care of your concern (and mine, too).

The only concern I have left is the fact everything is considered to be under __root__. This is an issue with remap-istanbul (reported here: SitePen/remap-istanbul#50).

Let me know if there is anything else you would like me fix! Thanks.

@delasteve
Copy link
Contributor Author

Found another concern, maybe someone can help. I am getting Not all files specified in sources could be found, continue with partial remapping. Has anyone experienced this or know what I am doing wrong?

@filipesilva
Copy link
Contributor
8000 filipesilva commented Jun 3, 2016

@delasteve can you tell me how to repro that error?

@delasteve delasteve force-pushed the feature/add-code-coverage branch from 79470a3 to dd08c48 Compare June 3, 2016 19:14
@delasteve
Copy link
Contributor Author
delasteve commented Jun 3, 2016

@filipesilva: it's an issue with karma-remap-istanbul. I am hesitant to change things too much with no tests. I don't have time to maintain the project (a permission I was given by the owner due to his lack of time to merge a PR).

I just released a version that will fix the timeout issue that was causing that error line. It was always executing the timeout even if all the files were found.

I just fixed the cli package.json to use the new version. It's going through testing now.

@delasteve
Copy link
Contributor Author

@filipesilva would you mind rerunning the build? AppVeyor looks like it had a network issue and while the build completed and tests were the same I had on my local, the TravisCI also failed.

Thanks!

@filipesilva
Copy link
Contributor

@delasteve I restarted both builds now.

@delasteve
Copy link
Contributor Author

I will take a look into the failures when I get home in a bit. Curious if it has something to do with my update to the karma-remap-istanbul plugin.

@devCrossNet
Copy link

@delasteve @filipesilva I tried the same approach as you and had the issue that the html report was not generated on the first run. Do you have the same issue? I have another approach that also removes the dependency to karma-remap-istanbul, you can check it here: https://github.com/devCrossNet/angular-cli/tree/coverage. I also made a pull-request to the remap-istanbul project that should solve the "missing folder structure" issue, you can see it here: SitePen/remap-istanbul#65. My approach will work after the pull-request is merged and I update the remap-istanbul dependecy. Let me know what you think.

@delasteve
Copy link
Contributor Author

@filipesilva I took a look locally, and it passes there. I don't know what's going on with CI.

@devCrossNet I like your approach towards th 8000 e solution. I am not a fan of karma-remap-istanbul as it depends on another plugin to run first. That is most likely (although unconfirmed) the cause of your html report woes (coverage reporter wasn't finished yet).

I wonder if we go the route of a new task, should we have a ng test --coverage flag?

@devCrossNet
Copy link

@delasteve I think coverage should be the default option. but with my solution, it is possible to implement a --coverage flag.

@delasteve
Copy link
Contributor Author

@devCrossNet I agree about it being default. At one point, --watch was a thing, but now it's the default. I just want to make sure the discussion happens before this goes in.

Also, I like your solution to this better than using the flakey karma plugin. How should we go about this? I would rather not just lift your code and put my name on the commit. Thoughts?

@devCrossNet
Copy link

@delasteve I am really new into contributing to projects on GitHub. I have no idea. Maybe you can merge my changes with yours? Then it should be a PR from us both

@filipesilva
Copy link
Contributor

@delasteve to be perfectly honest I don't know why travis is failing. The tests all pass and then it seems to hang. Perhaps there is a zombie process created by the new libs that isn't killed?

@delasteve
Copy link
Contributor Author

@filipesilva I almost want to say forget my PR and go with @devCrossNet's solution. It's been running for over 2 hours at this point on Travis. I am not found of the solution karma-remap-istanbul puts forth (waiting on another reporter to run), nor do I have want to try and fix it.

@devCrossNet: I am pretty sure the Angular team would like 1 commit per PR. Git only allows 1 author per PR. Personally, I would go ahead and rebase your changes on top of master, squash them into 1 commit, and submit a new PR.

@devCrossNet
Copy link

@delasteve ok, as soon as my changes are merged into remap-istanbul and I finished this whole topic. I will submit a new PR for this feature.

@devCrossNet
Copy link

@delasteve I updated my repository to use my fork from remap-istanbul. In my opinion, this can be a temporary solution for this feature. But I have another question - should the code coverage also work with ng test --watch=true?

@delasteve
Copy link
Contributor Author

@devCrossNet Got in touch with someone from SitePen. They will be taking a look at your PR in a bit. As for running with --watch=true, I would say yes.

@filipesilva
Copy link
Contributor

Don't worry too much about the number of commit guys, once it's ready to merge in I'll just squash them myself.

Regarding the watch, I agree that it should get coverage as well by default. If you implement a --coverage flag, then it should correctly interact with --watch., otherwise it can just default to having coverage everywhere.

@devCrossNet
Copy link

@delasteve @filipesilva thank you very much, guys. I will try to implement the coverage with the watch=true flag. I have no idea how to do that because the karma-server event "run_completed" is triggered before the coverage-final.json is written. maybe I have to set a timeout or something.

@devCrossNet
Copy link

@delasteve Now it works for ng test and ng test--watch=false. It is really fast and the usage feels good. It would be great if you can do a little review and maybe test it. devCrossNet@a7b3ebe

@delasteve
Copy link
Contributor Author

@devCrossNet it appears that there is an issue with your pull request for remap-istanbul. Do you need some help with it?

After that goes in, I definitely will be able to test your changes.

@devCrossNet
Copy link

@delasteve sorry for the delay. I was sick the last view days. I have to figure out what is the problem with remap-istanbul. Maybe the solution is just to test the values. I will ask him to give a reproducible example. It would be great if you can help me if you know the remap-istanbul project.

@delasteve delasteve force-pushed the feature/add-code-coverage branch from dd08c48 to 39dc1cb Compare July 8, 2016 23:08
@delasteve delasteve force-pushed the feature/add-code-coverage branch from 39dc1cb to f4c23ab Compare July 8, 2016 23:10
@devCrossNet
Copy link

@delasteve remap-istanbul merged my changes today. after they released the new npm version, I will update my code and make a PR. regards.

@filipesilva
Copy link
Contributor

Closed as this PR was made obsolete by #1455. Code coverage is in that PR though!

@Headcult
Copy link

I'm still facing an issue when I implemented Karma-Coverage in my Angular-CLI project. I’m not able to see the correct file names and contents in the HTML report. The coverage is fine but, the file location and name is messed up, it looks like it’s being picked up from the ‘tmp’ folder (tmp/broccoli_type_script_compiler-input_base_path-xrfIqZiR.tmp/0/src/app/). The remapping may have gone wrong. Any workaround or a fix too see the correct file contents within the report. Thanks in advance.

@filipesilva
Copy link
Contributor

@Headcult try the webpack preview build, that should be fixed: https://github.com/angular/angular-cli#webpack-preview-release-update

@delasteve delasteve deleted the feature/add-code-coverage branch January 17, 2017 06:33
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0