首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >量角器: ng e2e:如何解决“错误:连接ETIMEDOUT”错误?

量角器: ng e2e:如何解决“错误:连接ETIMEDOUT”错误?
EN

Stack Overflow用户
提问于 2017-09-26 15:38:03
回答 4查看 8.8K关注 0票数 9

我开发了英雄之旅角教程应用程序。之后,我为组件编写了测试。应用程序和组件测试做得很好。现在我想用Protractor开发E2E测试,但我无法让它们运行。

每次在命令行上运行ng e2e时,都会得到以下输出:

代码语言:javascript
复制
$ ng e2e
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2017-09-26T14:51:12.962Z
Hash: ef70100f8d31703b6b85
Time: 8035ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 3.16 MB {inline} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 209 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.6 kB {inline} [initial] [rendered]
(node:13556) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

webpack: Compiled successfully.
events.js:182
  throw er; // Unhandled 'error' event
  ^

Error: connect ETIMEDOUT 216.58.205.112:443
    at Object._errnoException (util.js:1026:11)
    at _exceptionWithHostPort (util.js:1049:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)

有关我的设置的一些希望有用的信息:

  • 该项目是由安圭拉CLI创建的。
  • 量角器安装在全球和当地。
  • 以下文件位于node_modules/webdriver-manager/selenium目录中:chromedriver_2.32.exe, chromedriver_2.32.zip, chrome-response.xml, gecko-response.json, selenium-server-standalone-3.5.3.jar, standalone-response.xml
  • 我使用代理属性运行webdriver-manager update
  • 如果我使用运行中的Selenium或directConnect: true配置运行该命令,这没有什么区别
  • 当浏览器被设置时,Chrome (Firefox有同样的问题)
  • 操作系统: Windows 10,浏览器: Chrome 51.0.2704.106米(64位)

protractor.conf.js文件:

代码语言:javascript
复制
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  /*seleniumAddress: 'http://localhost:4444/wd/hub',*/
  directConnect: true,
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  onPrepare() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

package.json文件:

代码语言:javascript
复制
{
  "name": "angular-tour-of-heroes",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "core-js": "^2.4.1",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.4.2",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "angular-in-memory-web-api": "^0.4.6",
    "codelyzer": "~3.1.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-firefox-launcher": "^1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

这是我第一次尝试用角度和量角器开发E2E测试。

谢谢您一直鼓励我!

更新

我不知道如果我运行webdriver-manager update就会执行ng e2e。所以我尝试了ng e2e --no-webdriver-update,使用这个命令,上面的错误不再出现了。我认为出现错误是因为没有设置代理,而且webdriver无法运行更新。

然而,现在我得到了一个新的错误。以下是完整的输出:

代码语言:javascript
复制
$ ng e2e --no-webdriver-update
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2017-09-27T06:50:31.482Z
Hash: ef70100f8d31703b6b85
Time: 8513ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 3.16 MB {inline} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 209 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.6 kB {inline} [initial] [rendered]
(node:12764) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

webpack: Compiled successfully.
[08:50:31] I/launcher - Running 1 instances of WebDriver
[08:50:31] I/direct - Using ChromeDriver directly...
[08:50:31] E/direct - Error code: 135
[08:50:31] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[08:50:31] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
    at Direct.getNewDriver (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\built\driverProviders\direct.js:63:31)
    at Runner.createBrowser (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\built\runner.js:195:43)
    at q.then.then (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\built\runner.js:339:29)
    at _fulfilled (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:863:30)
    at Promise.promise.promiseDispatch (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:796:13)
    at D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:556:49
    at runSingle (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:137:13)
    at flush (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
[08:50:31] E/launcher - Process exited with error code 135
EN

回答 4

Stack Overflow用户

发布于 2017-09-27 07:25:08

好吧,我解决了这个问题。这就是我所做的。

ng e2e运行webdriver-manager update命令。在我的例子中,这导致了ETIMEDOUT问题,因为在没有代理的环境中,它无法下载文件。相反,我必须使用ng e2e --no-webdriver-update

现在我有了Could not find update-config.json错误。

使用--proxy参数更新webdriver似乎并不能下载所有和/或正确的内容。我必须设置环境变量HTTP_PROXYHTTPS_PROXY,并运行webdriver-manager update --ignore_ssl命令。

现在量角器开始工作了。

票数 10
EN

Stack Overflow用户

发布于 2018-01-18 21:28:47

我发现webdriver-manager update尊重HTTPS_PROXY环境变量。尝试使用(公司)代理服务器HTTPS_PROXY环境变量http://********:80,重新启动VS代码或命令提示符(以获取更改),您应该可以运行e2e测试而不会出现问题。

票数 4
EN

Stack Overflow用户

发布于 2018-08-15 02:14:31

如果您是在网络风暴或Intellij编辑器。您可以设置HTTPS_PROXY变量,也可以在webstorm终端中设置。

代码语言:javascript
复制
SET https_proxy=http://yourcompanydomain.com:portnumber
SET http_proxy=http://yourcompanydomain.com:portnumber 

然后在终端中运行以下命令

代码语言:javascript
复制
ng e2e

一定会成功的

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46430648

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档