Reputation: 15566
My e2e tests were running fine and suddenly* this error is showing up. I have been trying to debug this for a while and is still clueless.
*suddenly
= Possible upgrade of windows. (not confirmed) &
Changed to new @angular/cli (I believe it worked fine after the update, but cannot recollect well)
Any hints on what would have gone wrong? Any inputs on which direction to go is also appreciated much. I am mostly clueless right now!
proxy.bat
set PROXY="http://xxxx.xxxx.com:3128"
set HTTP_PROXY=%PROXY%
set HTTPS_PROXY=%PROXY%
Error Log
> 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 } }));
}
};
Upvotes: 2
Views: 1631
Reputation: 15566
Make sure you have latest node
, npm
, protractor
.
To set proxy for npm, add it to your .npmrc
file (npm config list
will show the location of user config file) as:
proxy=http://proxy_url:port
https-proxy=http://proxy_url:port
registry=http://registry.npmjs.org/
strict-ssl=false
Use http://username:password@proxy_url:port
if proxy has authentication
Try either of the following to see if the above change worked:
npm config list;//also shows location of user settings file
npm config ls -l;//shows all defaults
To let protractor pickup your proxy do the following in cmd: (Related pull request)
set HTTP_PROXY=http://proxy_url:port
set HTTPS_PROXY=http://proxy_url:port
To find proxy url in Windows, open Internet Explorer.
Goto Tools>Internet Options>Connections>Lan Settings
In the [✓]Use automatic configuration Script, you can find a link to a .pac
file or you will get the proxy url from here itself.In case of .pac
open the url in browser and open the pac file when it gets downloaded, to the end of the file look for something like:
return "PROXY 120.42.240.53:3281; DIRECT";//this is your proxy URL.
(this worked for me, but there are different other solutions if you search for it)
In addition to these I have also removed readonly
from the node_modules folder.
Upvotes: 2