【发布时间】:2017-05-15 13:35:06
【问题描述】:
对于我的 nodejs 模块,我使用 Mocha 和 Chai 编写了一些单元测试。它们在 macOS 上运行良好,但在 Windows 上编译失败,出现以下编译器错误:
D:\projects\antlr4-graps>npm test
> antlr4-graps@1.2.0 test D:\projects\antlr4-graps
> mocha --compilers ts:ts-node/register,tsx:ts-node/register
D:\projects\antlr4-graps\node_modules\ts-node\src\index.ts:312
throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
^
TSError: ⨯ Unable to compile TypeScript
test\test.ts (17,1): Cannot find name 'describe'. (2304)
编译失败的代码是:
describe('antlr4-graps', function () {
这是完全有效的代码 (the full version of that file is on Github)。我仔细检查了 mocha 和 chai 是否安装为本地节点模块,包括它们的 TS 等效项(@type/chai 和 @type/mocha)。
如何修复编译?
【问题讨论】:
标签: node.js typescript mocha.js