visionmedia/mocha — pull request #1014 by jlipps (2013-10-23 16:08:44+00:00)
Title: Add option for dealing with flakey beforeEach hook

This addresses issue #581.

AFAICT the main contention there is whether support for flakiness should be built into mocha. I'm sympathetic to @visionmedia's point that in the typical unit-testing case, re-running a failed beforeEach hook is only going to be a waste of time.

However, use of mocha has become very widespread, and in my opinion needs to allow for different kinds of cases than unit testing. We proudly use mocha for our https://github.com/appium/appium tests, but are finding it difficult to get through a test suite because of the unfortunately intractable flakiness of the underlying automation mechanisms.

This pull request adds support hidden behind an optional flag: `--flakey-before-each`, and corresponding mocha option `flakeyBeforeEach`. If this is turned on, then a failure in a beforeEach hook will have the result of failing the test it's running before with the error that failed it, but not halting the execution of the suite as a whole.

I have also added an acceptance test modeled after the one for `--async-only`. Please advise if I should add a different kind of test for this new behavior as well.

Given that this contrib addresses the concerns of those of us who are pushing mocha to be used in a wider array of circumstances, and that it doesn't change the default behavior for those who are relying on it for their unit tests, I hope it will be reviewed and merged soon!