Angular CLI: 6.0.0
Node: 8.9.4
OS: darwin x64
Angular: 6.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... elements, forms, http, language-service, material
... platform-browser, platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.0
@angular-devkit/build-angular 0.5.12
@angular-devkit/build-optimizer 0.5.12
@angular-devkit/core 0.6.0
@angular-devkit/schematics 0.6.0
@ngtools/webpack 6.0.0-rc.10
@schematics/angular 0.6.0
@schematics/update 0.6.0
rxjs 6.0.0
typescript 2.7.2
webpack 4.6.0
This may not be an issue, but rather a lack of understanding of how the new cli config works.
Again, maybe I am not understanding how this works, but I would think that if I set the devServerTarget e2e option then whatever configuration that server has it should pull through during the e2e task.
ng e2e
** Angular Live Development Server is listening on localhost: 4200, open your browser on http://localhost:4200/ **
I would expect server to startup on the specified port that is set in myapp-app:serve.
If I set the port option directly in the myapp-app-e2e:e2e options section, then it does respect that and starts up the server on that port.
Same issue here, when I tried to add the options to the e2e part of the angular.json it failed because of Schema validation. Example:
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(publicHost).
Only overriding the port there was fine though but we need some more settings to get serve to work. I managed to override port and host (not publicHost tho) either in the package.json (ng e2e --host <bla>) or in the angular.json (added to the options: {} part of the `e2e definition), as a temporary work around.
Are we misunderstanding what the devServerTarget is refering to?
Same issue here. I was surprised to see that the port for e2e is different than what I specified in myapp:serve. For now overriding just port is fine, but I am confused nevertheless.
I am confused too. Documentation is very minimal and there needs to be more verbose examples of how to configure the angular.json file. Especially since the basic examples only show the argument way to define options, e.g --public-host, but doesnt explain if this is "publicHost" in the angular.json
I am a god damn legend. I got it working, here is an example for you guys.
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "Project:build",
"hmrWarning": false,
"host": "myproject.com",
"port": 8000
},
"configurations": {
"hmr": {
"hmr": true,
"browserTarget": "Project:build:hmr"
},
"production": {
"hmr": false,
"browserTarget": "Projectbuild:production"
}
}
},
Output message from Angular:
Angular Live Development Server is listening on myproject.com: 8000, open your browser on http://myproject.com:8000/ **
You've misunderstood the original issue. It's not about setting a port for serve target.
Earlier we run --serve=false with --base-url or baseUrl(protractor.conf) for remote testing, but now that don't work. Any news about this bug?
And i dont know why devServerTarget is a requirement either. --sever=false is a valid use case and now its gone
I was able to delete devServerTarget from angular.json, the change the baseUrl parameter in the e2e project's protractor.conf.js file and point the e2e test to another port on localhost. I imagine adjusting baseUrl to point to another server would work just as well.
Angular 6.0.8
With @tongfa's comment i was able to change host and port. Remove the "devServerTarget": "project-name:serve" like he mentions and in protractor.conf.js just update the baseUrl to contain both your host and port eg: baseUrl: 'http://project-name.local:8080/'
But really it should be picking it up as intended from the serve:options in angular.json.
@Smiter15 @tongfa it did not working for me. here is my configuration and I running ng e2e --configuration=e2e-ci --suite=home
"e2e-ci": {
"protractorConfig": "./protractor.conf.js",
"baseUrl": "https://udc.dev.finra.org"
}
I make it work and below is the stackoverflow link and details how it works
Heya, we weren't computing host and port correctly in our Protractor setup. https://github.com/angular/angular-cli/pull/12507 should fix it. Sorry about that!
This doesn't work for me, because it strips the appended path.
When I run the tests it opens https://localhost not https://localhost/test/local/ which is the production build I need to test. It strips the path information. This used to work before without any issue. It was highly configurable but has now become too opinionated, please revert back, or have a deprecation warning or something.
I can get http://localhost to work for now, but this is not a complete test and bugs will arrive in the future and I'll can do is blame the angular framework to my VP, which makes me look silly.
Please add the previous functionality back.
"e2e": {
"configurations": {
"noserve": {
"devServerTarget": "",
"baseUrl": "https://localhost/test/local/"
}
},
@MRHarrison You will have to take a look at your protractor.conf.js and see what URL you're using there.
Can you post the result of that file?
@Bjeaurn I changed the protractor.conf.js and removed baseUrl from angular.json file but same result.
```javascript
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/*/.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'https://localhost/test/local/',
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 } }));
}
};
Alright, you can still leave the baseUrl in the angular.json, but the entry point where Protractor connects to isn't directly linked to what's in the angular.json, that's just where the :serve is making it available.
I bet somewhere in your .e2e-spec.ts files you have a 'redirect' function redirecting to localhost or anything like that. Have you searched through all the .e2e-spec.ts files for localhost?
Only reason I know this by the way, is I ran into the exact same issue a week ago. I'm quite sure the application and framework are behaving as intended.
@Bjeaurn What version are you using? Can't find another reference. When I switch from https://localhost/test/local/ to http://localhost in angular.json I do notice that the protocol does switch from https to http. So I know the baseUrl arg is taking affect.
I confirm problem with URL stripping. We deployed many projects on a single Web server and using some path to access deployment.
For example, having project A with version 1.2 and 1.3, next project B with version 0.0.1 and 0.0.2, then web server on http://dev.mycompany.com. Finally a target URL is http://dev.mycompany.com/A/1.2 but test failed because http://dev.mycompany.com/ is not an Angular application ...
However as I have try to put baseUrl in Protractor configuration file, I suspect problem is on its side ?
I found solution ... or the problem. Default generated E2E is accessing '/' instead of browser.baseUrl. See e2e/src/app.po.ts
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
I am a god damn legend. I got it working, here is an example for you guys.
Output message from Angular:
Angular Live Development Server is listening on myproject.com: 8000, open your browser on http://myproject.com:8000/ **