2015-09-22 14 views
9

私はユニットテストをデバッグできるようにVisual Studioコードで起動設定を設定しようとしています。Typescriptでブレークポイントを設定するVisual Studioコードでジャスミンテスト

私のテストはTypescriptで書かれています。テストされたテストとコードは、ソースマップを持つ単一のjsファイルにコンパイルされます。

以下の設定では、jsファイルにブレークポイントを設定し、Visual Studioコードで停止時にtsファイルの行をハイライト表示させることができます。これは、ソースマップがある程度機能していることを示しています。しかし、tsファイルにブレークポイントを置くと無視されます。

tsファイルでブレークポイントを取得する方法についてのアイデアはありますか?

{ 
    "version": "0.1.0", 
    // List of configurations. Add new configurations or edit existing ones. 
    // ONLY "node" and "mono" are supported, change "type" to switch. 
    "configurations": [ 
     { 
      // Name of configuration; appears in the launch configuration drop down menu. 
      "name": "Unit tests", 
      // Type of configuration. Possible values: "node", "mono". 
      "type": "node", 
      // Workspace relative or absolute path to the program. 
      "program": "node_modules/jasmine/bin/jasmine.js", 
      // Automatically stop program after launch. 
      "stopOnEntry": false, 
      // Command line arguments passed to the program. 
      "args": ["JASMINE_CONFIG_PATH=test/script/jasmine.json"], 
      // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace. 
      "cwd": ".", 
      // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH. 
      "runtimeExecutable": null, 
      // Optional arguments passed to the runtime executable. 
      "runtimeArgs": ["--nolazy"], 
      // Environment variables passed to the program. 
      "env": { }, 
      // Use JavaScript source maps (if they exist). 
      "sourceMaps": true, 
      // If JavaScript source maps are enabled, the generated code is expected in this directory. 
      "outDir": "test/script" 
     } 
    ] 
} 

答えて

1

私は、VSコードを0.10.9に、Typescriptを1.8.2に更新しました。これが「今すぐ動作します」。

2

次の設定は問題なく動作し、ジャスミンテストをデバッグできます。

'use strict'; 

var Jasmine = require('jasmine'); 
var j = new Jasmine(); 

j.loadConfigFile('spec/support/jasmine.json'); 
j.configureDefaultReporter({ 
    showColors: true 
}); 
j.execute(); 

プロジェクトファイルの構造は次のとおりです:あなたlaunch.jsonで 次のように

{ 
    // Name of configuration; appears in the launch configuration drop down menu. 
    "name": "Launch Unit Tests", 
    // Type of configuration. 
    "type": "node", 
    // Workspace relative or absolute path to the program. 
    "program": "spec/runner.ts", 
    // Automatically stop program after launch. 
    "stopOnEntry": false, 
    // Command line arguments passed to the program. 
    "args": [], 
    // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace. 
    "cwd": ".", 
    // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH. 
    "runtimeExecutable": null, 
    // Optional arguments passed to the runtime executable. 
    "runtimeArgs": ["--nolazy"], 
    // Environment variables passed to the program. 
    "env": { 
     "NODE_ENV": "development" 
    }, 
    // Use JavaScript source maps (if they exist). 
    "sourceMaps": true, 
    // If JavaScript source maps are enabled, the generated code is expected in this directory. 
    "outDir": "dist/spec", 
    "request": "launch" 
} 

runner.tsがある

-spec 
--runner.ts 
--support 
----jasmine.json 
--folderWithTests1 
-dist 
--spec 
..... 

注 - "distが" フォルダがありますspecファイルはどこにビルドされています。したがって、 "outDir"は "dist/spec"に設定されます。

希望すると、これが役立ちます。

関連する問題