Alex Egli
Alex Egli

Reputation: 2064

Code coverage for jasmine with ES2018 code?

I just started using async/await in my nodejs code, and noticed that my code coverage tool cannot handle it, I get "Fatal error: Unexpected token" for any lines with async on them. I'm using karma and jasmine as my unit test framework, and grunt-jasmine-node-coverage for code coverage. I checked and grunt-jasmine-node-coverage hasn't been updated in years. I looked for a more modern code coverage library and couldn't find any that had been updated in the past year. I'm fine with using just npm instead of grunt to run my tasks, I know I'm way behind on that, but I couldn't find any code coverage frameworks recent enough that I think that would make a difference.

Does anyone know of a code coverage framework for JS code that works with ES2018 syntax?

Upvotes: 0

Views: 1326

Answers (1)

Alex Egli
Alex Egli

Reputation: 2064

I used nyc (https://github.com/istanbuljs/nyc) with jasmine (https://jasmine.github.io/pages/docs_home.html) and it worked great. My package.json config was:

"scripts": {
    "test":"jasmine",
    "coverage": "nyc --reporter=lcov npm run test"
  },
  "nyc": {
    "report-dir": "spec/coverage",
    "exclude": [
      "spec/**/*"
    ]
  },

Upvotes: 4

Related Questions