【问题标题】:Visual Studio Code: Execute Test scripts?Visual Studio Code:执行测试脚本?
【发布时间】:2016-06-15 12:46:16
【问题描述】:

我正在关注Redux Tutorial 并尝试在 Visual Studio Code 中使用 TypeScript 来实现它。本教程使用了Expect 库。

我的问题是:我有没有机会直接从 VisualStudio 代码执行 Expect-Tests(写在 *.ts 文件中),或者我绝对创建一个 HTML 页面和在浏览器中运行?后者似乎非常不方便。请注意,在这种情况下,要运行的文件是 TypeScript 文件,所以很遗憾,this answer 不起作用,因为 node 无法直接处理 TypeScript 文件。

【问题讨论】:

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


    【解决方案1】:

    不需要直接在 node 中运行 TypeScript,你可以将你的 *.ts 文件编译成 JavaScript *.js 并运行它们。

    您可以使用sample project 来掌握它。

    基本上,这些是运行测试的步骤:

    1. 将代码从 TypeScript 编译为 JavaScript。
    2. 将您的测试从 TypeScript 编译为 JavaScript。
    3. 在您选择的测试库中运行测试(例如mocha)。

    【讨论】:

      猜你喜欢
      • 2021-03-05
      • 2016-04-08
      • 2022-01-07
      • 2015-10-04
      • 2015-03-12
      • 2021-02-01
      • 2023-03-11
      • 2018-04-12
      • 1970-01-01
      相关资源
      最近更新 更多