caolan/nodeunit — pull request #270 by lipsmack (2014-08-02 09:57:00+00:00)
Title: Make running test groups idempotent

Currently the internal function `wrapGroup` deletes the `setUp` and `tearDown` method of any test group. When running from the command line, test groups will be provided by the Node module loader or module cache. This patch performs a shallow copy of the module object inside `wrapGroup` so that the original setup and teardown methods are preserved. This means that repeatedly running tests on the same module or file in the same execution context will always yield the same output.

Some background: I encountered a bug when running nodeunit via grunt-contrib-watch with process spawning disabled. In this environment, any tasks that invoke nodeunit will share a context - and more importantly, a module cache. As such, tests will fail after the first pass.