Ember-cli: importing blanket.js causes test runners to hang
Asked Answered
S

1

3

I'm currently using ember-cli with ember-qUnit for testing. I would also like to add code coverage results to the test output, so after some research blanketjs seemed the way to go. I installed blanket using:

npm install blanket

And moved the blanket folder into the ember-cli vendor folder. As I understand the way to import libraries is through the Brocfile.js which I am doing like so:

app.import('vendor/blanket/dist/qunit/blanket.js');

Using ember inspector it appears that blanket has been imported correctly, and the "enable coverage" checkbox has appeared at the top of the qUnit test results page. However the tests just hang and just say "running". No tests seem to run. When I use:

ember test -server

It says that it is "waiting for runners". Does anyone know what could be going wrong here?

I've looked around and it seems code-coverage with ember-cli is a tricky subject:

Ember CLI Code Coverage Reports

Thanks

Sepulture answered 18/9, 2014 at 8:30 Comment(0)
T
2

I installed it using ember-cli-blanket. I don't think you need to include it in your Brocfile.js, but instead import it in your tests/index.html after you import your test-support.js.

Blanket will probably make your runners hang for a big as it is essentially loading you entire app all over again.

For what it's worth, I haven't been able to get accurate test coverage using this method yet, but it's possibly user error.

Triumph answered 10/12, 2014 at 19:20 Comment(7)
I've tried using this method: Installing via npm install ember-cli-blanket, then using ember generate ember-cli-blanket, and including 'assets/blanket.js' file in 'tests/index.html'. I end up with 2 "Enable Converage" check boxes, and an inaccurate coverage of 100% so it's definitely progress!Sepulture
Have you done this more than once? I've looking into the blueprint, and it just naively injects itself into your existing code according to the plan, so you might just have some duplicate stuff in thereTriumph
If I don't include the assets/blanket.js file in the index file I do have one Enable Coverage box, however even with it checked no coverage results show. The blueprint seems to just include blanket-options.js and blanket-loader.js. Sometimes refreshing the tests page when the blanket.js file is included the coverage results do appear, and are less than 100% and more like I expected, however the page crashes with the error Uncaught Error: Could not find module ember/load-initializers.Sepulture
You are correct, you shouldn't have that assets/blanket.js file in your html. The crash sounds like it may be a code issue. I would check your app/app.js and make sure that you are importing loadInitializers properly, and that your version of ember-cli is up to date (0.1.4)Triumph
I've updated my app to ember-cli 0.1.4, and re-installed node and bower modules. Not including assets/blanket.js still just makes the enable coverage appear but no code coverage is run. Including the file causes these errors:Sepulture
Uncaught Error: error loading source script test-support.js:8175 GET http://localhost:35729/... tests:1 XMLHttpRequest cannot load http://localhost:35729/.... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. ... vendor.js:16934 Uncaught Error: Assertion Failed: The initializer 'container-debug-adapter' has already been registered VM12771:13966 Uncaught TypeError: Cannot read property 'pushFailure' of undefined VM12770:111254 Uncaught Error: Could not find module ember/load-initializersSepulture
Looks like an SSL issue. Make sure you setup your CORS headers in ember-cli to allow for cross site requests. Check out this page for more info on that. github.com/rwjblue/ember-cli-content-security-policyTriumph

© 2022 - 2024 — McMap. All rights reserved.