function setupHookTest(hookName) {
        return function () {
          const testFile = path.join(tempDir, 'test.js');
          const hookFile = path.join(tempDir, 'hook.js');

          copyFixture('__default__', testFile);
          copyFixture('options/watch/hook', hookFile);

          replaceFileContents(hookFile, '<hook>', hookName);

          return runMochaWatchJSONAsync(
            [testFile, '--require', hookFile],
            tempDir,
            () => {
              touchFile(testFile);
            }
          ).then(results => {
            expect(results.length, 'to equal', 2);
            expect(results[0].failures, 'to have length', 1);
            expect(results[1].failures, 'to have length', 1);
          });
        };
      }
/*.js'],
        tempDir,
        () => {
          replaceFileContents(
            dependency,
            'module.exports.testShouldFail = false',
            'module.exports.testShouldFail = true'
          );
        }
      ).then(results => {
        expect(results, 'to have length', 2);
        expect(results[0].passes, 'to have length', 1);
        expect(results[0].failures, 'to have length', 0);
        expect(results[1].passes, 'to have length', 0);
        expect(results[1].failures, 'to have length', 1);
      });
    });

    // Regression test for https://github.com/mochajs/mocha/issues/2027
    it('respects --fgrep on re-runs', async function () {
      const testFile = path.join(tempDir, 'test.js');
      copyFixture('options/grep', testFile);

      return expect(
        runMochaWatchJSONAsync([testFile, '--fgrep', 'match'], tempDir, () => {
          touchFile(testFile);
        }),
        'when fulfilled',
        'to satisfy',
        {
          length: 2,
          0: {tests: expect.it('to have length', 2)},
          1: {tests: expect.it('to have length', 2)}
        }
      );
    });

    describe('with required hooks', function () {
      /**
Helper for setting up hook tests

@param {string} hookName name of hook to test
@return {function}