gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 786 forks source link

Need help to use Istanbul for casperJS #833

Closed wushuangdaidai closed 7 years ago

wushuangdaidai commented 7 years ago

can't get branch and function

=============================== Coverage summary =============================== Statements : 8.82% ( 3/34 ) Branches : 0% ( 0/2 ) Functions : 0% ( 0/18 ) Lines : 8.82% ( 3/34 )

/t/casper/step-1.js:9 cov_X54oLzWEyc5EZtW05xGjqg.s['1']++;var config=require('../config');__cov_X54oLzWEyc5EZtW05xGjqg.s['2']++;var url=config.origin+'/pages/v2/account/step1';cov_X54oLzWEyc5EZtW05xGjqg.s['3']++;casper.userAgent(config.useragent);__cov_X54oLzWEyc5EZtW05xGjqg.s['4']++;casper.test.begin('',function(test){cov_X54oLzWEyc5EZtW05xGjqg.f['1']++;__cov_X54oLzWEyc5EZtW05xGjqg.s['5']++;phantom.clearCookies();cov_X54oLzWEyc5EZtW05xGjqg.s['6']++;config.userCookie.forEach(function(val){cov_X54oLzWEyc5EZtW05xGjqg.f['2']++;__cov_X54oLzWEyc5EZtW05xGjqg.s['7']++;phantom.addCookie(val);});cov_X54oLzWEyc5EZtW05xGjqg.s['8']++;casper.start(url,function(){cov_X54oLzWEyc5EZtW05xGjqg.f['3']++;__cov_X54oLzWEyc5EZtW05xGjqg.s['9']++;switch(config.userType){case 0:cov_X54oLzWEyc5EZtW05xGjqg.b['1'][0]++;__cov_X54oLzWEyc5EZtW05xGjqg.s['10']++;casper.waitForResource('/mobile/common/getUserLogin',function(){__cov_X54o

ReferenceError: casper is not defined at Object. (/***/casper/step-1.js:9:195) at Module._compile (module.js:570:32) at Object.Module._extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/istanbul/lib/hook.js:107:24) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Function.Module.runMain (module.js:604:10) at runFn (/usr/local/lib/node_modules/istanbul/lib/command/common/run-with-cover.js:122:16) at /usr/local/lib/node_modules/istanbul/lib/command/common/run-with-cover.js:251:17 at /usr/local/lib/node_modules/istanbul/lib/util/file-matcher.js:68:16