LoginSignup
23
26

More than 5 years have passed since last update.

WebStormでNode.jsアプリをデバッグする(Mocha, Typescript版もあり)

Posted at

WebStormだと様々な形式のNode.jsアプリが簡単にデバッグできます.
実際に画像で見てみましょう

単純なNode.jsアプリの場合

1. Javascriptを書いてブレークポイントを置く

rapture_20140528221455.png

2. 右クリック>Debug app.js

rapture_20140528221615.png

3. やったぜ

rapture_20140528221653.png

Mochaのテストをデバッグしたい場合

1. mochaを入れる

上メニューFile>Settings > Node.js and NPM > 緑の+ボタン > mochaをInstall Package
rapture_20140528221942.png

2. mochaのテストを書いてブレークポイントを置く

testというフォルダを作ってその中にテストJS
rapture_20140528224001.png

3. 上メニューRun>Edit Configurations

rapture_20140528221118.png

4. 左上の+ボタン>Mocha

rapture_20140528221230.png

5. Mochaの設定をしてOKで閉じる

スクリーンショット 2014-05-28 22.30.51.png

ほとんどの項目は初期のままでよい.
以下の項目は自分で指定する必要があるかも

項目名 意味
Mocha package mochaの場所.node_modules/mochaとなるはず
Test directory テストjsが入っているフォルダ

6. 右上にあるデバッグボタンを押す

rapture_20140528224122.png

7. やったぜ

rapture_20140528224205.png

Typescriptの場合

1. Typescriptを入れる

mochaを入れる手順と同じ
スクリーンショット 2014-05-28 22.43.33.png

2. Typescriptファイルを作るとヒントが出るのでAdd watcher

rapture_20140528224543.png

3. Typescriptを書いてブレークポイントを置く

rapture_20140528225356.png

3. コンパイルされたjsファイルで右クリック>Debug app.js

rapture_20140528225325.png

4. やったぜ

rapture_20140528225512.png

23
26
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
23
26