Karma测试中的Typescript断点不会在vscode中被Chrome调试器击中

时间:2018-07-19 11:54:27

标签: typescript visual-studio-code google-chrome-devtools karma-runner aurelia

我已经看到并阅读了大量similar questions and的答案,分别是tutorialsdocumentation。但是,没有人帮助我解决问题。

我有一个带有Typescript和Webpack的Aurelia应用程序。我使用Karma进行了测试,它运行良好(包括--watch)。现在,我想在VSCode中调试测试。 Chrome Debug Extension已安装,并且原则上可以正常工作:我可以插入debugger;语句,以便调试器在此时中断。

但是,断点不会受到打击。我尝试了有和没有源地图。我的启动配置如下:

    {
        "type": "chrome",
        "request": "attach",
        "name": "attach to karma's chrome",
        "port": 9333,
        "webRoot": "${workspaceRoot}",
        "sourceMaps": true,
        "pathMapping": {
            "/": "${workspaceRoot}/",
            "/base/": "${workspaceRoot}/"
        },
        "sourceMapPathOverrides": {
            //"webpack:///./*": "${webRoot}/*",
            //"webpack:///src/*": "${webRoot}/*",
            //"webpack:///*": "*",
            //"webpack:///./~/*": "${webRoot}/node_modules/*"
            "webpack:///myproject/./*": "${webRoot}/*",
            "webpack:///myproject/src/*": "${webRoot}/*",
            "webpack:///myproject/*": "*",
            "webpack:///myproject/./~/*": "${webRoot}/node_modules/*"
        },
        "trace": "verbose"
    }

webRoot对我来说很好,它是我在源映射中可以找到的基本文件夹。 sourceMapPathOverrides可能看起来很奇怪。原因是在源映射中,我找到了webpack://myproject/./test/unit/type-transformer/base.spec.ts之类的路径。我还尝试了带有注释的配置,也没有任何替代。

日志显示如下内容:

From client: setBreakpoints({"source":{"name":"base.spec.ts","path":"/path/to/myproject/test/unit/type-transformer/base.spec.ts"},"lines":[13],"breakpoints":[{"line":13}],"sourceModified":false})
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"setBreakpointsRequest","data":{"Versions.DebugAdapterCore":"6.6.0","Versions.DebugAdapter":"4.8.0","fileExt":".ts"}}}
To client: {"seq":0,"type":"response","request_seq":3,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":false,"line":13,"message":"The breakpoint will be ignored, because the generated code cannot be found (path mapping problem?).","id":1000}]}}

(该消息对我来说是德语的,因此可能与原始英文消息不完全匹配。)我发现奇怪的是,文件系统上的路径已发送到chrome(如path)。不知道如何将其解析为源映射中的正确条目。

如何配置调试器,以便断点起作用?

0 个答案:

没有答案