Mocha: Option to retry tests

Created on 27 Jan 2015  路  5Comments  路  Source: mochajs/mocha

Tests should be consistent. They should either always fail or always pass. Unit tests are generally pretty consistent. With functional tests, however, several factors outside of our control may cause a test to fail. For example, my functional testing stack consists of MochaJS, WebDriverJS, and BrowserStack. The tests usually pass. However, in some cases, like when the network is congested or BrowserStack is slow in creating a VM session, a test may fail.

Since mocha doesn't support retries yet, I have to re-run test suites in their entirety. With each suite taking a non-trivial amount of time (between 5 to 15 minutes) to complete, this solution isn't ideal.

It would be nice if mocha supported retries. If a test in a suite fails, then I could retry that test instead of of re-running the entire suite.

Most helpful comment

In case you end up here as I did: http://mochajs.org/#retry-tests

All 5 comments

:+1: from me. Re-running all tests is a waste.

Just an FYI @kpheng there are a couple of libraries out there that already to this. mocha-retry is one - which allows you to specify a number of retries per describe or it. Another is mocha-extra-shot which plugs directly into the runner which is a bit lower level.

if this use case is covered by 3p projects, it doesn't need to be in mocha core

In case you end up here as I did: http://mochajs.org/#retry-tests

3p = third party

Was this page helpful?
0 / 5 - 0 ratings

Related issues

delta62 picture delta62  路  3Comments

Swivelgames picture Swivelgames  路  3Comments

danielserrao picture danielserrao  路  3Comments

robertherber picture robertherber  路  3Comments

niftylettuce picture niftylettuce  路  3Comments