【问题标题】:Test Typescript unit test in debug mode using VSCode使用 VSCode 在调试模式下测试 Typescript 单元测试
【发布时间】:2021-04-09 15:32:57
【问题描述】:

我想使用 vs-code 在调试模式下运行 Typescript spec.ts。 通常,我从终端窗口运行它,如下所示:

npm run test:unit -- page.spec.ts

我添加了console.log 语句来识别值。有没有办法在 vs-code 中做到这一点?

当这个 npm 命令在终端上运行时,我看到正在执行的是 package.json 中的一个脚本

    "test:unit": "ngcc && jest --coverage --ci --config=jest.conf.json"

因此,我不清楚如何将其设置为在调试模式下运行。

我读过的所有帖子都使用mocha 或正在browser 中运行测试。这些是简单的单元测试,我想加入和退出。

不胜感激任何提示/建议。

【问题讨论】:

标签: typescript unit-testing visual-studio-code


【解决方案1】:

我能够通过执行以下操作来完成此操作:

   {
        "type": "node",
        "request": "launch",
        "name": " Unit Test",
        "program": "${workspaceRoot}\\node_modules\\jest\\bin\\jest.js",
        "args": [
           // "-i"
           "get-data.component.spec"
          
        ],
        "internalConsoleOptions": "openOnSessionStart",
    },

【讨论】:

    猜你喜欢
    • 2016-04-17
    • 2019-07-12
    • 2017-04-28
    • 2021-03-14
    • 1970-01-01
    • 2018-01-13
    • 2023-04-02
    • 2013-06-30
    • 1970-01-01
    相关资源
    最近更新 更多