Code coverage for Protractor tests in AngularJS

前端 未结 5 598
小鲜肉
小鲜肉 2020-12-29 12:10

I am running some e2e tests in my angularJS app with protractor (as recommended in the angularJS documentation). I\'ve googled around and cannot find any information on how

5条回答
  •  天涯浪人
    2020-12-29 12:13

    I managed to get it working, but it's a hack at the moment. I use one of the existing grunt istanbul plugins to instrument the code. Then I made a dummy spec that grabs the 'coverage' global variable and write it to a file. After that, you can create a report with any of the reporting plugins.

    The (very over-simplified) test looks like:

    describe('Output the code coverage objects', function() {
        it('should output the coverage object.', function() {
            browser.driver.executeScript("return __coverage__;").then(function(val) {
                fs.writeFileSync("/path/to/coverage.json", JSON.stringify(val));
            });
        });
    });
    

提交回复
热议问题