How to capture console.error with Karma unit test runner?

javascript, karma-runner, unit-testing

Solution

Karma does capture `console.error` (see https://github.com/karma-runner/karma/blob/415d0257c23ff7be07e240648bfff0bdefa9b0b6/client/karma.js#L70)

Make sure you set config `client.captureConsole: true` and use the latest Karma.

Problem

Karma will capture any messages written to `console.log` but not anything written to `console.error`. I understand that karma uses log4js under the hood. Is there any way to configure karma to capture `console.error`?

Original source