There is one long test, after which it is necessary to clean up the tracks. I use an after hook, but the execution time is longer than the standard 2000ms, which is why the whole test failed.
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test. For tests it is possible to change this timeout , but with after it does not work. I have a feeling that I missed something very simple ..
UP:
I made an example that looks more like my real test and which can reproduce the problem:
function long_async_function(cb){ setTimeout(cb,3000); } function clear_test_data(cb){ describe('clearing test', function() { this.timeout(3333); it('clear data and test it',function(done){ long_async_function(function(){ done(); console.log('Clearing test call after callback'); cb(); }); }); }); } describe('long test', function() { this.timeout(3333); it('do something',function(done){ long_async_function(done); }); after(function(done){ this.timeout(12000); clear_test_data(done); }); }); In this form, the test is performed 18 seconds. If you change the timeout in the after, the test execution time changes proportionally. After hook causes fails of the entire test due to exceeding the timeout, but at the same time, as the console shows, its done is invoked, but after an error with a timeout. What did I do wrong?
describein theafterhook. Brad of some sort - Dmitriy Simushev