blanket
blanket copied to clipboard
Functional Tests Coverage
Hi,
I would like to use blanketjs to record the javascript code coverage for functional tests that use Selenium to do the actions. I have found this #100 ancient issue, and there was a mention that this may be fixed in the future(which is now the past) using an adapters API.
Is it possible now? Would it be difficult to make such an adaptor? Has someone done it already?
Thanks.
A small update, it maybe that I haven't RTFM'd enough. Seems like there's the usage-blanket.js adaptor, which looks like the thing I need. I'll give it a try, hopefully it will work.
Could you please post back on how this works out for you?
Yes. I was able to inject it into the tested page, and it displays an overlay div. Clicking on the 'show results' makes it disappear. Btw, is there some javascript object where blanket saves the results? I would like to extract this result from the page after the functional tests finish running.
While playing around with the browser console, I have found only the report and setupCoverage functions, that look like can generate some results.
So, I have read the documents, cloned the repo, added a new concat rule to the gruntfile. I have copied most pieces from the Jasmine rule.
usage:{
options: {
banner: '<%= banner %>'
},
src: [
'<%= concat.esprima.dest %>',
'<%= concat.falafel.dest %>',
'src/blanket.js',
'src/blanket_browser.js',
'src/reporters/simple_json_reporter.js',
'src/config.js',
"src/blanketRequire.js",
"src/adapters/usage-blanket.js"
],
dest: 'dist/usage/blanket_usage.js'
},
This worked, and I got a concated(and minified) file, that should contain the Usage adapter and the simple json reporter.
Next I have modified the functional test to add the "data-cover" attribute to all the script tags on the page. And after that the test injects the custom blanket dist script into the page.
I get this error though
Uncaught TypeError: Cannot read property 'nodeValue' of undefined VM45:271(anonymous function)
VM45:271a.extend.utils.collectPageScripts VM45:271a.extend._loadSourceFiles
VM45:271(anonymous function) VM45:271blanket.beforeStartTestRunner.bindEvent
VM45:271a.extend._bindStartTestRunner VM45:271a.extend.beforeStartTestRunner
VM45:271(anonymous function)
Any ideas? Thanks.
Have you completed the Functional Tests Coverage?same issue for functional tests on phantomjs