使用 Visual Studio Code 在 Typescript Jasmine 测试中设置断点

使用 Visual Studio Code 在 Typescript Jasmine 测试中设置断点

问题描述:

我正在尝试在 Visual Studio Code 中设置启动配置,以便调试我的单元测试.

I am trying to set up a launch configuration in Visual Studio Code so that I can debug my unit tests.

我的测试是用 Typescript 编写的.测试和他们测试的代码被编译成一个带有源映射的 js 文件.

My tests are written in Typescript. The tests and the code they test are compiled into a single js file with a source map.

使用下面的配置,我可以在 js 文件中设置断点,并让 Visual Studio Code 在 ts 文件停止时突出显示该行.这表明 sourcemap 在某种程度上是有效的.但是,如果我在 ts 文件中放置一个断点,则它会被忽略.

With the configuration below I can set a breakpoint in the js file and have Visual Studio Code highlight the line in the ts file when it stops. This suggests that the sourcemap is working to some extent. However if I put a breakpoint in a ts file then it is ignored.

关于如何使 ts 文件中的断点起作用的任何想法?

Any ideas on how I can get breakpoints in the ts file to work?

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

我已将 VS Code 更新为 0.10.9,将 Typescript 更新为 1.8.2,现在正常工作".

I've updated VS Code to 0.10.9 and Typescript to 1.8.2 and this now "just works".