brean Posted May 18, 2015 Share Posted May 18, 2015 Hi, There is currently no test coverage for PIXI.JS.Are there any ideas how coverage of pixi.js could be generated? I have a very similar setup for my project ( pixi_ui - it is using everything that PIXI uses: gulp, testem, mocha+chai) and I think I will keep following PIXI (well... as long as it makes sense).But I have not found an easy solution that generates a coverage report for mocha+chai tests. Quote Link to comment Share on other sites More sharing options...
xerver Posted May 18, 2015 Share Posted May 18, 2015 Blanket.js, and Instanbul are both easy ways to generate coverage reports from mocha tests. Quote Link to comment Share on other sites More sharing options...
brean Posted May 18, 2015 Author Share Posted May 18, 2015 Hi xerver, thank you for your answer, I already took a small look at istanbul and blanket.js (and jscoverage) but how do I get them running with testem? There is a testem-istanbul example here:https://github.com/airportyh/testem/tree/master/examples/coverage_istanbulbut running an own server for tests seems wrong (I think that is the only solution for now, I will try it later if I do not get something else running). Accoring to the blanket documentation I just need to reference the blanket.js-file in the HTML for my test runner and add the data-cover attribute for all embedded js-files I want to test, but there is no HTML file for the tests in PIXI, so how do I create this?! For jscoverage (and other tools) I tired modifying the "launchers"->"node"->"command". But then the ./test/setup.js gets ignored and testem does not find chai anymore. So it all sounds easy but especially for the combination of tools in this setup (gulp, testem, browserify and chai) I can not find a way to get the coverage. Quote Link to comment Share on other sites More sharing options...
xerver Posted May 18, 2015 Share Posted May 18, 2015 Testem builds the index file for you based on your config. You can include the blanket file in your config, or use the methods they recommend for instanbul. There is nothing wrong with running your own server for coverage. Quote Link to comment Share on other sites More sharing options...
brean Posted May 19, 2015 Author Share Posted May 19, 2015 Hi xaver, thank you for your help, but I still can not get any coverage. Istanbul:I tried the istanbul-coverage server solution, but that only generates an empty report. Blanket:Adding the required "data-cover" for the files I want to test is not possible for a generated index file, or can I specify the files somewhere else? Everything else:I still have the problem that I can not run the tests from command line calling mocha directly. The command in the testem.json "launchers"->"node"->"command" does not work because it does not find chai. Quote Link to comment Share on other sites More sharing options...
brean Posted May 19, 2015 Author Share Posted May 19, 2015 Running this in the pixi.js-folder:./node_modules/.bin/mocha -r chai bin/pixi.js test/setup.js test/unit/**/*.test.js -R tap --recursive ./test/unitfinds chai, but it fails because without a browser document is not defined. Quote Link to comment Share on other sites More sharing options...
xerver Posted May 19, 2015 Share Posted May 19, 2015 Tests have to be run in the browser, I don't have time to look at this right now. The best I can offer is to google for other users who do testem browser tests with coverage. Good Luck! Quote Link to comment Share on other sites More sharing options...
brean Posted May 20, 2015 Author Share Posted May 20, 2015 Using karma I was able to run my tests in a browser and generated a text-based coverage (the html output jasmine in combination with browserify does not work).My karma config can be found here:https://github.com/brean/pixi_ui/blob/master/test/karma.conf.js(based on https://github.com/karma-runner/karma-coverage/issues/16 ) Because I want cool HTML-coverage I will dive into blanket next. Quote Link to comment Share on other sites More sharing options...
brean Posted May 21, 2015 Author Share Posted May 21, 2015 I have a working blanket setup now! I created my own testrunner html file files based on this http://geowarin.github.io/javascript/2014/12/27/coverage-with-gulp-phantom-and-mocha.html and this http://alex-seville.github.io/blanket/test/mocha-browser/adapter.html I run browserify manually and load the file in the browser. I only get coverage for the combined .js file. But I can work with this, it is better than to the karma-jasmine solution because now I see which lines exactly are not covered by tests (instead of just numbers in the jasmine-solution). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.