title: How do I debug errors from karma-server?
body: <p>I'm using <code>karma</code> along with <code>karma-typescript</code> (but this isn't an Angular project, so I'm not using <code>angular-cli</code>).</p>
  
  <p>About half of my test runs generate an error  <em>after</em> all of the tests have passed, and I'm stumped as to how to proceed. Here's the output.</p>
  
  <pre><code>$ karma start karma.conf.js --single-run --jenkins
  21 02 2019 09:43:38.104:INFO [compiler.karma-typescript]: Compiling project using Typescript 3.2.4
  21 02 2019 09:43:53.795:INFO [compiler.karma-typescript]: Compiled 21 files in 15446 ms.
  21 02 2019 09:43:57.633:INFO [bundler.karma-typescript]: Bundled imports for 21 file(s) in 3328 ms.
  21 02 2019 09:43:59.695:INFO [karma-server]: Karma v4.0.0 server started at http://0.0.0.0:9876/
  21 02 2019 09:43:59.720:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
  21 02 2019 09:43:59.757:INFO [launcher]: Starting browser ChromeHeadless
  21 02 2019 09:44:01.220:INFO [HeadlessChrome 72.0.3626 (Windows 10.0.0)]: Connected on socket 16JL3Xy0xm-ri3aBAAAA with id 59122393
  HeadlessChrome 72.0.3626 (Windows 10.0.0): Executed 0 of 110 SUCCESS (0 secs / 0 secs)
  [1A[2KHeadlessChrome 72.0.3626 (Windows 10.0.0): Executed 1 of 110 SUCCESS (0 secs / 0.061 secs)
  ...
  [1A[2KHeadlessChrome 72.0.3626 (Windows 10.0.0): Executed 110 of 110 SUCCESS (2.695 secs / 2.341 secs)
  TOTAL: 110 SUCCESS
  21 02 2019 09:44:05.251:ERROR [karma-server]: { Error: read ECONNRESET
      at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
  error Command failed with exit code 1.
  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command
  </code></pre>
  
  <p>(The <code>--jenkins</code> flag is used in my <code>karma.conf.js</code> primarily to determine whether <code>ChromeHeadless</code> is used instead of <code>Chrome</code> -- see below).</p>
  
  <p>I'm fairly certain that this error isn't coming from my code.</p>
  
  <p>Relevant packages:</p>
  
  <pre><code>    "@types/jasmine": "^3.3.8",
      "@types/jasminewd2": "^2.0.6",
      "awesome-typescript-loader": "^5.2.1",
      "jasmine": "^3.3.1",
      "jasmine-core": "^3.3.0",
      "karma": "^4.0.0",
      "karma-chrome-launcher": "^2.2.0",
      "karma-cli": "^2.0.0",
      "karma-jasmine": "^2.0.1",
      "karma-jasmine-html-reporter": "^1.4.0",
      "karma-junit-reporter": "^1.2.0",
      "karma-typescript": "^4.0.0",
      "ts-loader": "^5.3.3",
      "typescript": "^3.2.4"
  </code></pre>
  
  <p>Finally, here's my <code>karma.conf.js</code>:</p>
  
  <pre><code>module.exports = function(config) {
    const jenkins = config.jenkins;
    config.set({
      basePath: '',
      frameworks: ["jasmine", "karma-typescript"],
      plugins: [
        require('karma-jasmine'),
        require("karma-chrome-launcher"),
        require("karma-typescript"),
        jenkins ? require('karma-junit-reporter') : require('karma-jasmine-html-reporter')
      ],
      client:{
        clearContext: false // leave Jasmine Spec Runner output visible in browser
      },
      files: [
        "src/**/*.ts"
      ],
      preprocessors: {
        "src/**/*.ts": "karma-typescript"
      },
      reporters: [
        'progress', (jenkins ? 'junit' : 'kjhtml'), 'karma-typescript'
      ],
      browsers: [jenkins ? 'ChromeHeadless' : 'Chrome'],
      karmaTypescriptConfig: {
        tsconfig: "./tsconfig.json",
        coverageOptions: {
          exclude: [/mock/, /\.spec\.ts$/, /testing-utils/]
        }
      },
      colors: !jenkins,
      logLevel: config.LOG_INFO,
      autoWatch: !jenkins,
      singleRun: jenkins,
      junitReporter: {
        outputDir: 'karma-results',
        outputFile: 'karma-results.xml'
      }
    });
  };
  </code></pre>