t2ym/scenarist

[test][Suite.js][istanbul] No coverage reports for Suite.js with native async/await

Closed this issue · 2 comments

t2ym commented

With Suite.js using native async/await, istanbul cannot generate coverage reports.

Root Cause:

The current version of JS parser esprima, on which istanbul depends, cannot properly parse async/await syntax.

Workaround (for Node):

  • Step 1: npm install istanbul-espree
  • Step 2: Patch node_modules/istanbul-espree/lib/instrumentor.js in istanbul-espree with ecmaVersion: 8 from ecmaVersion: 7 in ESP.parse()
  • Step 3: Use Node 7: nvm use 7
  • Step 4: node --harmony ./node_modules/istanbul-espree/lib/cli.js cover ./node_modules/mocha/bin/_mocha test/src/test.js --report lcov -- -R spec

Workaround (for WCT): Not Verified Yet

  • Install node_modules/web-component-tester-istanbul/node_modules/istanbul-espree
  • Patch it as above
  • Rename istanbul-espree folder as istanbul
  • Run on an async/await-ready browser like Chrome 55+
t2ym commented

Use instanbul@1.1.0-alpha.1

  • t2ym/web-component-tester-istanbul#wct6 has to be updated as well to use instanbul@1.1.0-alpha.1
t2ym commented

Close the issue as wct-istanbul 0.12.1 and nyc 11.0.3 can properly report coverage with native async/await since scenarist 1.1.9.