4

我正在开发一个刚刚创建的带有 TypeScript 和单元测试的 Vue cli 项目。

我知道 Vue cli 测试使用mocha-webpack来运行测试。当我mocha-webpack在终端上键入时,测试运行正常。

但我想使用mocha-test-explorer,一个用于 mocha 测试的 VS Code 扩展。为了更好的编程体验。

我安装了扩展并配置如下:

"mochaExplorer.files": "tests/**/*.ts",
"mochaExplorer.require": "ts-node/register"

但是我仍然看不到测试。test-explorer 显示休闲输出:

(function (exports, require, module, __filename, __dirname) { import { expect } from 'chai'
                                                              ^^^^^^
SyntaxError: Unexpected token import

我知道那是因为 mocha 没有通过 webpack 加载文件。

我应该怎么做才能在 VSCode 的mocha-test-explorer扩展(或任何其他 gui 扩展)中看到mocha-webpack测试?

4

0 回答 0