Mih*_*goe 4 javascript mocha.js
看着其他问题,无法真正找到问题的原因.我正在尝试导入模块并使用mocha进行测试.
import chai, {
expect
}
from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import System from 'systemjs';
import '../public/config.js';
chai.use(sinonChai);
describe('helperModule', () => {
let module;
before(function () {
return System.import('./public/js/helper.js')
.then((mod) => module = mod);
});
describe('Module loading', function () {
it('should load', function(){
expect(module.default).to.not.be.undefined;
});
});
});
Run Code Online (Sandbox Code Playgroud)
运行npm test命令时出现以下错误.
1) helperModule "before all" hook:
Error: timeout of 2000ms exceeded. Ensure the done() callback is being
called in this test.
Run Code Online (Sandbox Code Playgroud)
不确定在哪里完成回调.如果您需要有关我正在使用的任何软件包的任何额外信息,我将使用它们编辑我的问题.
期望在测试完成时调用done()回调.有些库会为您隐式执行此操作,您也可以将完成传递给其他将成功调用它的函数.如果需要手动完成,可以将done指定为稍后调用的测试函数的参数.
describe('Module loading', function () {
it('should load', function(done){
expect(module.default).to.not.be.undefined;
done();
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9189 次 |
| 最近记录: |