【发布时间】:2018-09-23 22:11:51
【问题描述】:
我需要为我的 Typescript 应用程序编写单元测试。我使用 Mocha 测试框架。 我的网络应用程序中有内部模块(A)和 B 类。
namespace A {
export class B {
constructor() {
}
}
}
我需要为 B 类写一些单元测试。
/// <reference path="path/A.ts" />
import { expect } from 'chai';
describe('B test', function () {
describe('#constructor()', () => {
it('Should create B with default data', () => {
let b = new A.B();
expect(b.age).to.equal(90);
});
});
});
我正在使用命令开始我的测试:
mocha --watch --recursive path/Tests
但每次在终端我都会收到错误消息:
ReferenceError: A is not defined
A - 是我的内部模块,我无法导出它。以某种方式,如何测试内部模块的 B 类?
【问题讨论】:
标签: asp.net unit-testing typescript npm mocha.js