E2E tests only ever check against localhost:4200.
Run ng e2e my-app-e2e --baseUrl=anyurl
or
set baseUrl in cypress.json then run e2e tests
v 8.2.0 of nx
I've tried many different combinations (ng e2e, ng e2e --watch, ng e2e my-project-e2e) they all have the same result.
I dug into the source code and it appears as though the baseUrl is ignored when the devServerTarget is specified in angular.json. I was able to remove this option and verify that it picks up the baseUrl. However, removing this option also appears to prevent nx from building standing up the application. For my usage this is great!
However, it may be worth documenting this a bit more for folks trying to achieve non-trivial things during CI/CD.
@dpsthree That is correct.
Would someone like to contribute a fix? The line to change would be here:
https://github.com/nrwl/nx/blob/master/packages/cypress/src/builders/cypress/schema.json#L49
Make sure to run yarn documentation afterwards to regenerate the documentation.
I believe this is an code issue too. I really like nrwl serving the angular application but I need to override cypress's baseUrl
Hey Folks, I looked into it and I got it fixed in my branch.
@FrozenPandaz This issue is not related to the documentation. @Steven-Harris was right about the code issue. We need to check if the baseUrl is passed in, because at the time being, devServerTarget is always truthy, thus setting the baseUrl to http://localhost:4200.+
I expanded the predicate and there is a PR coming to fix this issue.
diff --git a/packages/cypress/src/builders/cypress/cypress.impl.ts b/packages/cypress/src/builders/cypress/cypress.impl.ts
index 3e4113d..233dd36 100644
--- a/packages/cypress/src/builders/cypress/cypress.impl.ts
+++ b/packages/cypress/src/builders/cypress/cypress.impl.ts
@@ -57,7 +57,7 @@ function run(
}
return (!legacy
- ? options.devServerTarget
+ ? (options.devServerTarget && !options.baseUrl)
? startDevServer(options.devServerTarget, options.watch, context).pipe(
map(output => output.baseUrl)
)
@mehrad-rafigh, I would still expect for the dev server to be started if the baseUrl is passed in,

The CLI is overriding any baseUrl set in cypress.json
Hi @Steven-Harris
You are right. I will update my PR asap
Reading through these comments and thinking back to what I wanted to achieve it sounds like this one setting is conflating two ideas. IMO e2e should always serve but also respect the baseUrl. It would be nice if there were a second command that respects all of the Nx settings and runs cypress without serving the application. This command should also respect the baseUrl setting.
Yes it would be very useful to be able to run my cypress specs against both local and hosted environments and compare the results.
I think this issue can be solved by:
skipServe which will skip the builder serving your application. This is equivalent to the devServerTarget being empty but reads better and makes it easy to invoke come CI. We can keep the same behavior so there is no breaking change.Examples:
What do you all think? I can submit a PR for these changes if they are desired.
Edit: #3744
The main issue, not being able to execute tests on another host seems to have been fixed by pull request https://github.com/nrwl/nx/pull/3487 and released in version 9.6.0
So it is now possible to pass --base-url https://github.com
One issue still remains, the application is still being built. This should not be needed since the use case here is that we want to run our tests on a remote hosted application. Should we create a new issue for this @FrozenPandaz?
As @ZachJW34 said before we should add a parameter like --serve with a default value of true.
I will try to see if i can create a pull request for this
@stefan-karlsson you can bypass the app being build with --dev-server-target=''
There is another issue here on github which mentions this
Most helpful comment
I think this issue can be solved by:
skipServewhich will skip the builder serving your application. This is equivalent to thedevServerTargetbeing empty but reads better and makes it easy to invoke come CI. We can keep the same behavior so there is no breaking change.Examples:
What do you all think? I can submit a PR for these changes if they are desired.
Edit: #3744