function AugmentReportersFactory(reporters, settingsJson) {
  const settings = JSON.parse(settingsJson);

  // Augment each reporter in the list.
  for (const reporter of reporters) {
    // Shim the renderBrowser function to add the number of test cases not yet
    // processed (passed, failed, or skipped).
    // The source we are patching: https://github.com/karma-runner/karma/blob/d8cf806e/lib/reporters/base.js#L37
    const orig = reporter.renderBrowser;
    reporter.renderBrowser = (browser) => {
      const results = browser.lastResult;
      const processed = results.success + results.failed + results.skipped;
      const left = results.total - processed;
      return orig(browser) + ` (${left} left)`;
    };

    // If we're not filtering explicitly, log any skipped tests.
    if (!settings.filter) {
      reporter.specSkipped = (browser, result) => {
        reporter.writeCommonMsg(result.fullName + ' SKIPPED\n');
      };
    }
  }

  // Return a dummy middleware that does nothing and chains to the next
  // middleware.
  return (request, response, next) => next();
}
This is a factory for a "middleware" component that handles requests in
Karma's webserver.  We don't handle any actual requests here, but we use this
plugin to get access to the reporters through dependency injection and
augment them to display the number of tests left to be processed.

This is useful when running tests locally on many browsers, since you can
see more clearly which browsers are still working and which are done.

This could have been done through a fork of Karma itself, but this plugin
was clearer in some ways than using a fork of a now-extinct project.

@param {!Array<karma.Reporter>} reporters
@param {string} settingsJson
@return {karma.Middleware}