2015-09-22 6 views
9

Próbuję skonfigurować konfigurację uruchamiania w kodzie Visual Studio, aby umożliwić debugowanie testów jednostkowych.Ustawianie punktów przerwania w testach Jasmine maszynopisu za pomocą kodu Visual Studio Kod

Moje testy są napisane w Maszynopisie. Testy i kod, który testują, są kompilowane w jeden plik js z mapą źródłową.

Za pomocą poniższej konfiguracji mogę ustawić punkt przerwania w pliku js i po zakończeniu programu Visual Studio Code podświetl linię w pliku ts. Sugeruje to, że sourcemap działa w pewnym stopniu. Jednak jeśli wstawię punkt przerwania w pliku ts, zostanie on zignorowany.

Wszelkich pomysłów, w jaki sposób można uzyskać punkty przerw w pliku ts do pracy?

{ 
    "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" 
     } 
    ] 
} 

Odpowiedz

1

Zaktualizowałem kod VS do 0.10.9 i Maszynopis do wersji 1.8.2, a teraz "po prostu działa".

2

Poniższa konfiguracja działa dobrze dla mnie i pozwala na debugowanie testów jaśminowych. W swojej 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" 
} 

The runner.ts jest następujący:

'use strict'; 

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

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

Struktura pliku projektu jest:

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

Uwaga - "dist" to folder gdzie tworzone są pliki spec ts. Dlatego "outDir" jest ustawiony na "dist/spec".

Mam nadzieję, że to pomoże.

Powiązane problemy