Verify that the done () callback is called in this test (Mocha, Chai, Sinon)

Looking at other questions, you cannot find the cause of the problem. I am trying to import a module and test it with 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;
        });
    });
});

When you run the command npm test, the following error appears.

1) helperModule "before all" hook:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being
 called in this test.

Not quite sure where to put the completed callback. If you need more information about any packages that I use, I will edit my question with them.

+4
source share
1 answer

, done(). , , . , , .

describe('Module loading', function () {
    it('should load', function(done){
        expect(module.default).to.not.be.undefined;
        done();
    });
});
+7

All Articles