-
Notifications
You must be signed in to change notification settings - Fork 50
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
Proof of concept of a more sustainable coverage approach. #147
base: master
Are you sure you want to change the base?
Conversation
@@ -47,6 +47,19 @@ | |||
System.bundles = []; | |||
} | |||
|
|||
var systemInstantiate = System.instantiate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment somewhere in this new block of code explaining what it is doing/why? Looks like it replaces paths of the coverage files to include the /base/
path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxwellpeterson-wf Not a problem, I'll add the comments, but I'll also leave you with a quick explanation for now. That code is converting the paths from a system ('file://') format into urls. Including /base/
is just one aspect of that, and it should probably not be hard coded. This part is necessary because the Istanbul instrumentation happens on the system, but the execution happens on the browser. In other words, say file "x" is on your system. Before Karma launches the browsers, file "x" is prepossessed and instrumented by Istanbul, we then take that source and store in an object for the browser to access. But when the browser gets it, all the "urls" are system paths (i.e. file:///home/project/x.js). So we first need to extract only the unique portion (i.e "project/x.js" - the fileKey
) to retrieve the source of the file from the object and then convert the paths in the source's content, whose dependencies still has it's "urls" in system file format, to actual urls (i.e. http://localhost:8080/base/project/x.js). I hope that clarifies a bit.
I think this is looking great, thanks for such a substantial contribution! @evanweible-wf want to take a look? |
Yeah looks good to me as well! |
@maxwellpeterson-wf @evanweible-wf Thanks for the positive feedback! I'll look into what needs to be cleaned up and update this pr with a release candidate for you guys to test in the next few days/weeks. |
this is looking great - is there any ETA on a RC? |
@sergei-maertens sorry, I hadn't noticed that @m-a-r-c-e-l-i-n-o had rebased. I'll take another look today! |
After two days of diving into way too much source code I have a working coverage with ES6 + React/JSX set up, so I can continue and there's no hurry, but this does seem cleaner and saner than our current setup :-) |
@evanweible-wf @sergei-maertens I was waiting (but also had other responsibilities) on this pr to move forward, and it was finally accepted a few days ago. I'll be updating this pr with a much cleaner version by tomorrow, it's pretty much done. |
@m-a-r-c-e-l-i-n-o sounds great! |
d0fa726
to
b543659
Compare
Updated this pr with a decent release candidate. It passed the unit and lint tests, and runs just fine on one of my local projects. I've done no isolated tests, but it should be fine for now. @maxwellpeterson-wf @evanweible-wf @sergei-maertens Please pull down this pr locally and let me know if any of you have issues. Couple of things to note:
|
I will try it out asap.
|
Any thoughts on this, guys? |
RavenNumber of Findings: 0 |
13c92f2
to
ade90eb
Compare
This is looking good. @sergei-maertens did you get a chance to try it out? |
Oh shuck - I completely forgot about this since we're using our fork at the
|
@evanweible-wf @maxwellpeterson-wf @trentgrover-wf Hold off on this merge, I'm going to use it in a pretty complex project in the next few days, it'll be a good chance to more thoroughly test and patch this baby, if needed. |
@m-a-r-c-e-l-i-n-o great, thanks! |
@m-a-r-c-e-l-i-n-o This pull request has merge conflicts, please resolve. |
ade90eb
to
5514084
Compare
@m-a-r-c-e-l-i-n-o Tried out using your branch with your version of remap-istanbul as you described above, and it seems to be almost working. I get the following error: After uncommenting We have a setup that only does coverage when verifying the whole project, so my suspicion is that the error might occur when coverage is disabled. Haven't dived that deeply into it yet, just wanted to give some feedback :) |
@cyrixmorten Thank you for the feedback, I appreciate it!
You mean it works after you comment that line out? (As oppose to uncommenting, since it should already be uncommented.) And I think you are right about this error being thrown only when coverage is disabled, this property would likely not be set if the coverage preprocessor hasn't ran. |
Yeah, I meant that i commented it out :-) Though I might have drawn an early conclusion on to what extend it was working.. I got the coverage console output, but not the files written to coverage folder. I realised that I had forgotten to add This however unfortunately spawned a new wall of errors in the line of:
and
To be fair it is a fairly big project that I try to test and I am new to the whole world of jspm, so may very well be a configuration problem on my end. Had it working with our previous setup that was based on npm + browserify. |
Eureka!! :-D Think the problems were entirely on my end. My final discovery was that I had failed to remove all traces of After removing it from plugins and reporters, I successfully got a full coverage report with files and everything 👍 As mentioned, we conditionally enable coverage, which now looks like this:
With frameworks and plugins as follows:
|
@cyrixmorten Yay! Glad you resolved it -- it did look like a configuration issue. So that first issue "TypeError: Cannot read property 'tempDirectory' of undefined" is fairly straight forward to address, and I'll see if I can do it today or tomorrow. |
@m-a-r-c-e-l-i-n-o Yeah, well actually I did not need to alter anything in karma-jspm after the final correction. It may however be a nice gesture to throw an error if there are karma-coverage references in the configuration since it apparently does not play well together with this library. Our code is by the way an angular project of ~4k loc with 107 unit/midway tests. Just to note that it is clearly capable of handling coverage of more than trivial examples. |
…strumentation for systemjs/jspm/transpiler projects, provide new reporter using remap-istanbul and modified adapter for attaching instrumentation
See #178 for a simpler, likely more efficient solution. |
The popular karma-coverage does not work as expected for me, mainly because Istanbul will try to instrument es6/es7 files and fail. As mentioned here, the workaround would be to use karma-babel-preprocessor, but there are two issues with this approach:
Here lies a proof of concept for allowing jspm to do all the heavy lifting with practically no additional configuration. This approach has been successfully used in node-jspm-jasmine — I helped author it. I'm not suggesting that this be merged blindly, but do open room for discussion. If there is a better approach, please do let me know!
Notice that the "reporter.js" file, along with its local file dependencies, are nearly identical to the one in the karma-coverage project, with almost all modifications occurring inside here.