如何在Angular 6单元测试中调试HeadlessChrome 0.0.0(Linux 0.0.0)ERROR {" isTrusted":true}? [英] How to debug HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR { "isTrusted": true } in Angular 6 unit test?

查看:638
本文介绍了如何在Angular 6单元测试中调试HeadlessChrome 0.0.0(Linux 0.0.0)ERROR {" isTrusted":true}?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行我的测试套件时,我在一个完全不同的单元测试中得到一个错误,而不是我工作过的那个。我做错了什么?

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

如果我注释掉某些测试,比如在A类中,另一个测试在组件B中失败。如果我将这些测试注释掉,则另一个测试在组件C中失败。 这些测试最近都没有更新过,所以没有一个测试失败。

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.

我在这个问题有些人将此问题归因于node_mo dules文件夹。但是,我刚刚通过重新安装node_modules文件夹来缓解了类似的问题。这是一个常见的错误吗? 开发人员不应该一直删除并重新安装node_modules文件夹。我一定做错了,但我一直在做的就是像往常一样进行单元测试。

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.

如何调试和修复此无头Chrome错误,以便我可以恢复单元测试?

以下是我的环境的一些统计数据:

Here are some stats about my environment:

相关的依赖版本:

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

相关的Karma.conf设置:

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,


推荐答案

我其实做过通过删除node_modules文件夹并重新安装它以及回滚两次提交单元测试来解决此问题。我仍然不确定导致此问题的原因或卸载并重新安装node_modules文件夹的原因。但它实际上确实有效。

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.

编辑:我还注意到,当我进行了两次具有相同描述的单元测试时,此错误再次出现。同样,我不确定这是否是唯一的原因,但改变单元测试描述似乎也解决了它。我希望错误更具描述性。

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 Problem still occurring regularly and none of the issues listed in the answer are present.

这篇关于如何在Angular 6单元测试中调试HeadlessChrome 0.0.0(Linux 0.0.0)ERROR {" isTrusted":true}?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆