Hasan Setiawan

Write, write, write give your wings on code!

Follow me on GitHub

JavaScript Mocha Error Timeout Require Done Callback

Got this issue on testing with Mocha

I try to run test with Mocha which testing a function that returned a promise, then I got this issue.
Here is my code look like:

              
                import expect from 'expect';

                describe('Some Module Testing', () => {
                  describe('Some function testing', () => {
                    expect(result).toBe(true);
                  });
                });
              
            

The solution

Then I figuring out how to solve the issue, and do this to my code. And the issue is gone.

              
                import expect from 'expect';

                describe('Some Module Testing', () => {
                  describe('Some function testing', (done: Function) => { // done parameter
                    expect(result).toBe(true);
                    done(); // done callback.
                  })
                });