title: How to debug HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR { "isTrusted": true } in Angular 6 unit test?
body: <p>When I run my test suite, I get an error in a totally different unit test than the one I've been working in. What am I doing wrong?</p>
  
  <pre><code>HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR
  {
      "isTrusted": true
  }
  </code></pre>
  
  <p>It is then followed by some build steps and the following error during test execution:</p>
  
  <pre><code>HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR
    An error was thrown in afterAll
    [object ErrorEvent] thrown
  </code></pre>
  
  <p>If I comment out certain tests, say in class A, another test fails in Component B. If I comment those out, another test fails in Component C. <em>None of these tests has been updated recently so none of them should be failing.</em></p>
  
  <p>I saw in <a href="https://stackoverflow.com/questions/45722256/how-do-i-debug-a-object-errorevent-thrown-error-in-my-karma-jasmine-tests">this question</a> that some people attribute this issue to the node_modules folder. However, I just mitigated a similar issue to this by reinstalling the node_modules folder yesterday. Is this that common of an error? <strong>It can't possibly be the case that developers are supposed to consistently delete and reinstall the node_modules folder.</strong> I must have done something wrong but all I've been doing is unit testing like usual.</p>
  
  <p><strong>How can I debug and fix this Headless Chrome error so that I can get back to unit testing?</strong></p>
  
  <p>Here are some stats about my environment:</p>
  
  <p>Relevant Dependency versions:</p>
  
  <pre><code>"@angular/cli": "6.0.8",
      "@angular/compiler-cli": "6.0.6",
      "@angular/language-service": "6.0.6",
      "@types/jasmine": "~2.5.53",
      "@types/jasminewd2": "~2.0.2",
      "@types/node": "~6.0.60",
      "codelyzer": "^4.0.1",
      "jasmine-core": "~2.6.2",
      "jasmine-spec-reporter": "~4.1.0",
      "karma": "~1.7.0",
      "karma-chrome-launcher": "~2.1.1",
      "karma-cli": "~1.0.1",
      "karma-coverage-istanbul-reporter": "^1.2.1",
      "karma-jasmine": "~1.1.0",
      "karma-jasmine-html-reporter": "^0.2.2",
      "ng-diff-match-patch": "^2.0.6",
      "protractor": "~5.1.2",
      "ts-node": "~3.2.0",
      "tslint": "~5.7.0",
      "typescript": "2.7.2",
      "@angular-devkit/build-angular": "~0.6.8"
  </code></pre>
  
  <p>Relevant Karma.conf settings:</p>
  
  <pre><code>reporters: ['progress', 'kjhtml'],
      port: 9876,
      colors: true,
      logLevel: config.LOG_INFO,
      autoWatch: true,
      browsers: ['ChromeHeadless'],
      singleRun: false,
      customLaunchers: {
        ChromeHeadless: {
          base: 'Chrome',
          flags: [
            '--headless',
            // '--disable-gpu',
            '--no-sandbox',
            // Without a remote debugging port, Google Chrome exits immediately.
            '--remote-debugging-port=9222',
          ],
        }
      },
      browserDisconnectTolerance: 8,
      browserNoActivityTimeout: 60000,
      browserDisconnectTimeout: 20000,
  </code></pre>