LoginSignup
2
0

More than 5 years have passed since last update.

Typescriptをavaでテストしてnycでカバレッジ

Posted at

結構詰まった。備忘。Node.js環境。

テストをビルドする

ちなみにtsconfigtsc -p tsconfig.jsonで指定できる。

tsconfig.json
{
  "compilerOptions": {
    "target": "es6",
    "module": "es6",
    "outDir":"./test",
    "moduleResolution": "node",
    "inlineSourceMap": true
  }
}

inlineSourceMapが重要。ソースマップがビルド結果のファイル内に含まれる。
なぜかsourceMapではうまく行かなかった。

テスト

avaes6のテストはそのままでは動かなかった。
もっといいやり方がありそう。

{
  "babel": {
  "presets": [
      "es2015",
      "stage-2"
    ]
  },
  "ava": {
    "require": [
      "babel-register"
    ],
    "babel": "inherit"
  }
}

テストのファイル指定は必要に応じて。

$ nyc ava

以上。
nycは自動的にsourcemapを辿ってtsのカバレッジを出してくれるっぽい?

2
0
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
0