2

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?

HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR
{
    "isTrusted": true
}

It is then followed by some build steps and the following error during test execution:

HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR
  An error was thrown in afterAll
  [object ErrorEvent] thrown

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. None of these tests has been updated recently so none of them should be failing.

I saw in this question 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? It can't possibly be the case that developers are supposed to consistently delete and reinstall the node_modules folder. I must have done something wrong but all I've been doing is unit testing like usual.

How can I debug and fix this Headless Chrome error so that I can get back to unit testing?

Here are some stats about my environment:

Relevant Dependency versions:

"@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"

Relevant Karma.conf settings:

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,
Knight
  • 576
  • 7
  • 19

1 Answers1

2

I did in fact resolve this issue by deleting the node_modules folder and reinstalling it as well as rolling back two commits worth of unit tests. I'm still not sure what causes this issue or why uninstalling and reinstalling the node_modules folder works. But it did in fact work.

EDIT: I also noted that this error showed up again when I had two unit tests with the same description. Again, I'm not sure if that was the sole cause, but changing unit test descriptions seems to have resolved it as well. I wish the error were a little more descriptive.

FURTHER EDIT: Problem still occurring regularly and none of the issues listed in the answer are present.

Knight
  • 576
  • 7
  • 19
  • Any updates on this or if you were able to get it resolved? – cheesydoritosandkale Sep 26 '18 at 16:38
  • I was not. I believe it occurs more when the source maps flag is set to true: `--source-map=true`. However, other than that, I have no leads. You could try flipping between `--source-map=true` and `--source-map=false` to check and see both if you have any hidden errors that the source maps flag is hiding for some reason or if the error goes away under one of those conditions. If you find out more info, please post here so I too can learn more about this issue. – Knight Sep 26 '18 at 19:04
  • hmmm I don't have that flag at all. I will let you know if we figure anything out. – cheesydoritosandkale Sep 26 '18 at 20:58