본문 바로가기
기타/Javascript

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

by 죠부니 2018. 7. 5.
반응형

Mocha

테스트 코드 작성중

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.


Timeout 추가로 해결

https://mochajs.org/#timeouts


describe('a suite of tests', function() {
  this.timeout(500);

  it('should take less than 500ms', function(done){
    setTimeout(done, 300);
  });

  it('should take less than 500ms as well', function(done){
    setTimeout(done, 250);
  });
})

추가로 참고할점은

ArrowFunction 사용시 this를 알아먹지 못한다.

https://mochajs.org/#arrow-functions

describe('my suite', () => {
  it('my test', () => {
    // should set the timeout of this test to 1000 ms; instead will fail
    this.timeout(1000);
    assert.ok(true);
  });
});


테스트 할때는 그냥 ArrowFunction 버리고 기존 function으로 작성하는게 좋을듯하다.

반응형

'기타 > Javascript' 카테고리의 다른 글

WindowTimers  (0) 2018.07.27
Array filter  (0) 2018.07.10
NPM  (0) 2018.06.19
알파벳 증가 // alphabet increment  (0) 2018.05.31
Modules  (0) 2018.05.29