Closed adamsea closed 9 years ago
I am having this same problem. My options in my gruntfile are almost exactly the same and I'm experiencing the same issue.
Here's the qunit portion of my grunt file:
qunit: {
all: {
options: {
urls: [
"http://localhost:8282/exsellsior/?test"
],
coverage: {
src: ['js/**/*.js'],
instrumentedFiles: 'temp/',
htmlReport: 'coverage/html',
cloverReport: 'coverage/clover'
}
}
}
}
I've also noticed that the temp/ directory remains empty throughout the tests - so there are no instrumented files generated
Thanks!
Scot
I noticed "phantomjs.on('qunit.coverage', function(coverage) { ... })" never runs.
I had this problem as well and added baseUrl: '.'
to my qunit.options.coverage, and that fixed it.
If this really is the fix, might be nice to make that the default, or at least document it better.
Unfortunately, @iangilman, this does not fix the problem. Besides, the baseUrl defaults to '.' already.
Interesting. I'm using 0.4.5 and explicitly setting baseUrl definitely fixes it for me. Here's my config:
qunit: {
coverage: {
options: {
urls: [ "http://localhost:8000/test/coverage.html" ],
coverage: {
src: ['src/*.js'],
htmlReport: 'coverage/html/',
instrumentedFiles: 'temp/',
baseUrl: '.',
disposeCollector: true
}
}
}
},
If I don't include the baseUrl, I get 100%s for everything; if I do, I get actual coverage numbers.
The other thing I found that was important was to make sure the files that matched my src
setting were included on the page via <script>
tag.
Anyway, sorry my fix isn't working for you!
I think the issue has been fixed with this pull request: https://github.com/asciidisco/grunt-qunit-istanbul/pull/34
Quick update: I was able to get this working with a modification to my baseUrl config. This was really due to my misunderstanding of the config (which was resolved once I looked through the code a bit more). In the example above my test url is 'http://127.0.0.1:9090/tests/qunit/index.html'
, which points to the physical path app/public/tests/qunit/index.html
. However baseUrl
is intended to be for the physical path of the host for the qunit page, in this case app/public
. Once updated to that value I get sensible coverage reports.
I think the docs could stand a better example to explain this, so I'll create a PR to do that. Thanks for the help all!
Hello,
Are there any samples of using the baseUrl option with a qunit test served via http? I currently have the following in my Gruntfile:
Which runs the tests successfully but doesn't not generate an accurate coverage report (claims 100% coverage on 0 files). An instrumented coverage.tmp file is placed in the plugin install directory, but that's it.
Thanks for any help you may be able to provide! -Eric