How to debug HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR { “isTrusted”: true } in Angular 6 unit test?

狂风中的少年 提交于 2019-12-11 12:35:32

问题


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,

回答1:


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.



来源:https://stackoverflow.com/questions/51863488/how-to-debug-headlesschrome-0-0-0-linux-0-0-0-error-istrusted-true-in-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!