Override mocha default timeout

1,416 views
Skip to first unread message

Carl Erik Kopseng

unread,
Dec 11, 2014, 4:05:17 AM12/11/14
to karma...@googlegroups.com
Running mocha tests manually one can override the default timeout of 2000ms by specifying --timeout 5000. I don't see how I can achieve this using the Karma runner. Am I missing something? 

I know I can manually override timeouts in each test, but that won't do here. Usually I set a timeout of 100ms in each unit test to catch logic that should run instantaneous, but on our slow Amazon server I have to filter away all timeouts using sed before running the tests. Unfortunately, some of the slow tests, especially ones running on Browserstack, can use more than 2 seconds, so I would like to specify a default of ten seconds or more.

Carl Erik Kopseng

unread,
Dec 14, 2014, 8:46:15 AM12/14/14
to karma...@googlegroups.com
This is very poorly documented, but I assembled bits and pieces from both the Mocha and karma-mocha docs to make it work. Turns out, all you need to add is the following to your config to change the default timeout:

client: {
      mocha: {
        timeout : 20000 // 20 seconds - upped from 2 seconds to allow slow BrowserStack Android emulators to complete
      }
    }

I will add that to my existing guide on setting up a successful BrowserStack based testing regime.

Regards,
Carl-Erik
Reply all
Reply to author
Forward
0 new messages