我的e2e测试运行正常且突然*出现此错误。我一直试图调试这一段时间,但仍然一无所知。
*suddenly
=可能升级Windows。 (未确认)&
更改为新的@ angular / cli(我相信它在更新后运行良好,但无法回忆起来)
任何可能出错的提示?任何方向的输入也很受欢迎。我现在几乎无能为力!
proxy.bat
set PROXY="http://xxxx.xxxx.com:3128"
set HTTP_PROXY=%PROXY%
set HTTPS_PROXY=%PROXY%
错误记录
> ng e2e
> ** NG Live Development Server is running on http://localhost:49152 ** 0% compiling 10% building modules 0/1 . . .
> webpack: Compiled successfully. events.js:160
> throw er; // Unhandled 'error' event
> ^
>
> Error: tunneling socket could not be established, statusCode=400
> at ClientRequest.onConnect (C:\xxxxx\xxxx\web\angular\node_modules\tunnel-agent\index.js:165:19)
> at ClientRequest.g (events.js:291:16)
> at emitThree (events.js:116:13)
> at ClientRequest.emit (events.js:194:7)
> at Socket.socketOnData (_http_client.js:395:11)
> at emitOne (events.js:96:13)
> at Socket.emit (events.js:188:7)
> at readableAddChunk (_stream_readable.js:176:18)
> at Socket.Readable.push (_stream_readable.js:134:10)
> at TCP.onread (net.js:548:20)
的package.json
{
"name": "angular",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor",
"mavenbuild": "node ./node/node_modules/angular-cli/bin/ng build --prod --base-href ngrepair-web"
},
"private": true,
"dependencies": {
"@angular/common": "^2.4.0",
"@angular/compiler": "^2.4.0",
"@angular/core": "^2.4.0",
"@angular/forms": "^2.4.0",
"@angular/http": "^2.4.0",
"@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.4.0",
"@angular/router": "^3.4.0",
"core-js": "^2.4.1",
"primeng": "^2.0.0",
"rxjs": "^5.1.0",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.6"
},
"devDependencies": {
"@angular/cli": "^1.0.0-rc.0",
"@angular/compiler-cli": "^2.4.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-spec-reporter": "0.0.28",
"protractor": "~5.1.1",
"ts-node": "~2.0.0",
"tslint": "~4.4.2",
"typescript": "~2.0.0"
}
}
protractor.conf.js
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
/*global jasmine */
var SpecReporter = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:8080/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e'
});
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
答案 0 :(得分:1)
确保您拥有最新的node
,npm
,protractor
。
要为npm设置代理,请将其添加到.npmrc
文件(npm config list
将显示用户配置文件的位置):
proxy=http://proxy_url:port
https-proxy=http://proxy_url:port
registry=http://registry.npmjs.org/
strict-ssl=false
如果代理有身份验证,请使用http://username:password@proxy_url:port
尝试以下任一操作以查看上述更改是否有效:
npm config list;//also shows location of user settings file
npm config ls -l;//shows all defaults
要让量角器接收您的代理,请在cmd中执行以下操作: (相关pull request)
set HTTP_PROXY=http://proxy_url:port
set HTTPS_PROXY=http://proxy_url:port
要在Windows中查找代理网址,请打开Internet Explorer。
转到工具>互联网选项>连接>局域网设置
在[✓] 使用自动配置脚本中,您可以找到.pac
文件的链接,或者您将从此处获取代理网址。如果是{{1在浏览器中打开url并在下载时打开pac文件,到文件末尾查找类似的内容:
.pac
(这对我有用,但如果你搜索它会有不同的其他解决方案)
除了这些,我还从node_modules文件夹中删除了return "PROXY 120.42.240.53:3281; DIRECT";//this is your proxy URL.
。