Looking at other questions, can't really find the cause of the problem. I am trying to import a module and test it using 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;
});
});
});
I get the following error when running the npm test
command.
1) helperModule "before all" hook:
Error: timeout of 2000ms exceeded. Ensure the done() callback is being
called in this test.
Not really sure where to put the done callback. If you need any extra information about any packages I am using I will edit my question with them.
There's an expectation that a done() callback is called when your test is complete. Some libraries do this implicitly for you, and you can also pass done to other functions that will call it on success. If you need to do it manually, done can be specified as a parameter of your test function to be called later.
describe('Module loading', function () {
it('should load', function(done){
expect(module.default).to.not.be.undefined;
done();
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With