LoginSignup
2
2

More than 5 years have passed since last update.

ispartaが動かないときの緊急対処方法

Last updated at Posted at 2015-03-02

追記: isparta@2.2.0 で修正されました

いつからかははっきりしないのですが、ES6 に対応したカバレッジ計測ツール isparta@2.1.0 でコードの変換に失敗してレポートが生成されない場合があります。

> babel-node node_modules/.bin/isparta cover --report text --report html --report lcov node_modules/.bin/_mocha

Transformation error; return original code
[TypeError: Cannot read property 'transform' of undefined]

...

No coverage information was collected, exit without writing coverage information

この問題の issue は babel にあがっていて、モジュールのインポート方法が変わったことにあります。

isparta の方にプルリクエストが来ているのですが、まだマージされていません(というかCIでエラーになってる)

まあ、修正されるのは時間の問題だろうとして、とりあえず今すぐカバレッジレポートを作りたい場合の対処方法です。

  1. 好きなエディタで node_modules/isparta/lib/instrumenter.js を開く
  2. 19行目を以下のように修正
- var babel = _interopRequire(require("babel-core"));
+ var babel = require("babel-core");
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2