2017-01-09 6 views
2

ブレークポイントにヒットすることができますが、いくつか問題があります。VSCode es6 mochaユニットテストとjsxファイルでデバッグする方法

  • コードがES5であり、それが唯一の.jsでブレークポイントにヒット
  • をデバッグすることは不可能です。 .jsxファイルでヒットする必要があります。
  • これでMocha.optsは全く機能していないようです。私は--compilers jsx:babel-registerを追加して、.jsから.jsxへの名前を変更しようとしましたが、ブレークポイントはそれ以上ヒットしません。それは完全に作業を停止しているように見える

モカオプション:

--require babel-register 
--require test/util/dom.js 
--require expect 
--compilers jsx:babel-register 

Launch.json

{ 
    "version": "0.2.0", 
    "configurations": [ 
    { 
     "request": "launch", 
     "name": "Debug Mocha Test", 
     "type": "node", 
     "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", 
     "args": [ 
     "test/**/*.spec.js", //I need to get this working with .jsx files 
     "--require", "babel-register" 
     ], 
     "cwd": "${workspaceRoot}", 
     "runtimeExecutable": null, 
     "env": { } 
    } 
    ] 
} 

答えて

5

が、これはノードデバッガのバグであることが判明しました。私はすべての問題を次のように変更して修正しました。

"type": "node" to "type": "node2"

Launch.json

{ 
    "version": "0.2.0", 
    "configurations": [ 
    { 
     "request": "launch", 
     "name": "Debug Mocha Test", 
     "type": "node2", 
     "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", 
     "args": [ 
     "test/**/*.spec.jsx", 
     "--colors", "--no-timeouts" 
     ], 
     "cwd": "${workspaceRoot}", 
     "runtimeExecutable": null, 
     "env": { } 
    } 
    ] 
} 

mocha.opts:weinandから取ら

--require babel-register 
--require test/util/dom.js 
--require expect 
--compilers jsx:babel-register 

回答。

また、ルートアプリケーションに"retainLines": trueという名前の.babelrcファイルが必要です。ここで例えば、私の.babelrcファイルは次のとおりです。

{ 
    "presets": [ 
     "es2015", 
     "stage-2", 
     "react" 
    ], 
    "plugins": [ 
     "transform-es2015-modules-umd" 
    ], 
     "retainLines": true 
} 

あなたがbad option: --inspect=...を取得した場合は、試してみて、ノードの新しいバージョンをインストールします。

+0

"type": "node"を使用して "protocol": "inspector"を追加すると、vscodeの現在のバージョンと同じように見えます。しかし、この答えは私にデバッグをもたらしました - ありがとう! – scolestock

関連する問題