2015-09-22 8 views
9

के साथ टाइपस्क्रिप्ट जैस्मीन परीक्षणों में ब्रेकपॉइंट्स सेट करना मैं विजुअल स्टूडियो कोड में लॉन्च कॉन्फ़िगरेशन सेट अप करने का प्रयास कर रहा हूं ताकि मैं अपने यूनिट परीक्षणों को डीबग कर सकूं।विजुअल स्टूडियो कोड

मेरे परीक्षण टाइपस्क्रिप्ट में लिखे गए हैं। उनके द्वारा परीक्षण किए गए परीक्षण और कोड को एक स्रोत मानचित्र के साथ एक जेएस फ़ाइल में संकलित किया जाता है।

नीचे कॉन्फ़िगरेशन के साथ मैं जेएस फ़ाइल में ब्रेकपॉइंट सेट कर सकता हूं और दृश्य स्टूडियो कोड टीएस फ़ाइल में लाइन को हाइलाइट करते समय हाइलाइट करता है। यह सुझाव देता है कि स्रोतमैप कुछ हद तक काम कर रहा है। हालांकि अगर मैं एक 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

मैंने वीएस कोड को 0.10.9 और टाइपस्क्रिप्ट को 1.8.2 तक अपडेट किया है और यह अब "बस काम करता है"।

2

निम्न कॉन्फ़िगरेशन मेरे लिए ठीक काम करता है और जैस्मीन परीक्षणों को डीबग करने की अनुमति देता है। अपने launch.json में:

'use strict'; 

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

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

परियोजना फ़ाइल संरचना है:

{ 
    // 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 
..... 

नोट - "जिले" फ़ोल्डर है जहां spec ts फाइलें बनाई गई हैं। इसलिए "आउटडियर" को "dist/spec" पर सेट किया गया है।

आशा है कि इससे मदद मिलेगी।

संबंधित मुद्दे