Code coverage for Protractor tests in AngularJS

前端 未结 5 596
小鲜肉
小鲜肉 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 12:19

    To add to ryanb's answer, I haven't tried this but you should be able to use something like gulp-istanbul to instrument the code and override the default coverage variable, then define an onComplete function on the jasmineNodeOpts object in your Protractor config file. It gets called once right before everything is closed down.

    exports.config = {
    
      // ...
    
      jasmineNodeOpts: {
        onComplete: function(){
          browser.driver.executeScript("return __coverage__;").then(function(val) {
            fs.writeFileSync("/path/to/coverage.json", JSON.stringify(val));
          });
        }
      }
    };
    

提交回复
热议问题