LoginSignup
7
5

More than 5 years have passed since last update.

karmaで実行するJavaScriptのテストにdebuggerを仕込む

Last updated at Posted at 2016-09-08

実行環境

  • npm: 3.9.5
  • karma: 0.13.10

手順

  1. テスト対象のJavaScriptコード、あるいはテストコードでブレイクポイント貼りたい箇所に debugger を記述
  2. --single-run=false オプションを追加してkarmaを実行
    • 例: $ karma start ./karma.conf.js --browsers=PhantomJS_custom --single-run=false
    • package.jsonにscriptsとして保存しておくと、npm testといったショートカットで実行できるので楽
  3. karmaのプロセスにdebuggerが刺さるので、http://localhost:9000/webkit/inspector/inspector.html?page=2 を開く
  4. Happy debugging!

参考: Debugging Karma Unit Tests

7
5
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
7
5