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
Coverage in addon files not working in ember-cli 1.13.13 #100
Comments
I noticed this yesterday as well after upgrading a number of addon repositories to 1.13.13 - I originally thought my code was at fault, but that wasn't the case (I stepped through line by line and everything was being executed). My current theory is that it's somehow related to this change https://github.com/twokul/ember-cli-release-notes/commit/bd5ac542c0d6dd8e095553d6528ec40ae4be6b4e, but it's a very loose theory. |
Doesn't appear to be that theory - looking into ember-cli-test-loader now |
👍 thanks for looking into this! |
No problem, was causing me headaches as well |
Interesting... how come it worked for tests in dummy/* but not for tests on file in addon/*? |
Just a theory again, but there is the split between loading the app and the tests - probably plays a role in this. From the tests/index.html:
I've tried changing order, but no luck so far |
As far as I can tell the only parts of the addon files that are "covered" are the loading of the module itself - the rest of the code has already been executed by the time the coverage lines are put in place. |
I'll try this in a mocha project tomorrow. I have one or two addons that are 1.13.13 and don't recall seeing this -jeff
|
I'm running all of my addons with mocha currently and the test project I just put together was qunit - it's happening in both unfortunately. |
I turned autostart off to observe require order - all tests and jshints are required and instrumented prior to the start being called, then when the tests are running the dependencies are required and instrumented. It appears at this point the instrumentation happens after the test is run. I can't recall how this worked before so I'm going to set up a 1.13.8 addon and run the same sequence. |
1.13.8 results:
So at this point we have a handle on what the issue is at least. I have to take off for tonight, I'll try to dig at this more tomorrow - @rwjblue and @stefanpenner any insights on the change in behavior? |
The difference to note would be between the 1.13.13 screenshot and 1.13.8 screenshot in terms of the test execution (done vs. paused at the component test) |
I got some debugging in on @offirgolan's project. The regression was introduced in loader.js (https://github.com/ember-cli/loader.js/commits/master) between 3.3.0 and 3.4.0 There was a fairly substantial refactoring internally - my suspicion is that the 'global' require that we're patching is now shrouded for certain code paths. There was an error message reported in #85 that I cleaned up when we monkey patch require. (to no avail and expecting none) In short, the dependencies of the tests (at least those in the addon) are going down a different code path and never being instrumented Will try to carve out some time for this tomorrow, but up against some hard deadlines - so other thoughts welcome |
I think it's this line: https://github.com/ember-cli/loader.js/pull/54/files#diff-73f82623658278cf03c2acf12426f916R86 loader.js is using findModule internally to resolve 'defined' modules - it used to read
and now does:
still not sure what to do about it but naively replacing that line with
puts the coverage back to > 94% cc: @stefanpenner - any thoughts on making our require hack safer? supported? |
Do you guys just need to intercept all requires? I can likely make a hook or something, if someone gives me a TL;DR |
Yes and the
|
@jschilli can you link me to where that is done currently? |
Try not to freak out at the ugly dependency code =) |
I upgraded from Ember CLI 1.13.6 to 2.2.0-beta.6 and coverage dropped from 100% to 22%. |
Can you retest this with version 0.9.1 (and be sure to update blanket.js via |
nice. that fixed the issue for me. thx. |
In ember-cli 1.13.12, I had ~95% coverage but once I upgrade to ember-cli 1.13.13, it dropped to ~50% with no other changes. What I noticed, is that all lines in my addon tests were red, but tests for files in my dummy app were working fine.
Coverage: https://codeclimate.com/github/offirgolan/ember-cp-validations/coverage
Code Climate Feed: https://codeclimate.com/github/offirgolan/ember-cp-validations
Repo: https://github.com/offirgolan/ember-cp-validations
You can check out the blanket-options.js file there as well as the npm and bower dependencies.
The text was updated successfully, but these errors were encountered: