-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Set up cypress in cypress #19602
feat: Set up cypress in cypress #19602
Conversation
…on and ensure proxied websockets with cypress in cypress are allowed
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
…ing it is a global
@lmiller1990 regarding #19602 (comment) I think as I was going through I was just ensuring that we are being consistent everywhere with the namespace. Good to know that package is going away though. |
packages/app/package.json
Outdated
"cypress:run-cypress-in-cypress": "cross-env HTTP_PROXY_TARGET_HOST=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", | ||
"cypress:launch": "yarn cypress:run-cypress-in-cypress gulp open --project ${PWD}", | ||
"cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project ${PWD}", | ||
"cypress:run:ct": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --component --project ${PWD}", | ||
"cypress:run:e2e": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project ${PWD}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only concern was that if we set HTTP_PROXY_TARGET_HOST
/ CYPRESS_REMOTE_DEBUGGING_PORT
here, we might miss it if Cypress is started from the root of the project, etc.
Can we set these as additional "internal" config values that we can set on the packages/app/cypress.config.ts
? It looks like they're only accessed when the browser is opened, so that should be fine since the config is sourced prior to that. @brian-mann thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not to since they're not like... official config values / flags, and may end up getting removed anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what CYPRESS_REMOTE_DEBUGGING_PORT
does anyway... is this the port like in --inspect-brk=[port]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brian-mann CYPRESS_REMOTE_DEBUGGING_PORT is the port that is used to launch the chrome debugger. I need a way to ensure that the parent and child are using the same port.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a lot of these already:
cypress/cli/types/cypress.d.ts
Lines 2896 to 2923 in 29f5c64
// Internal or Unlisted at server/lib/config_options | |
autoOpen: boolean | |
browserUrl: string | |
clientRoute: string | |
configFile: string | |
cypressEnv: string | |
devServerPublicPathRoute: string | |
isNewProject: boolean | |
isTextTerminal: boolean | |
morgan: boolean | |
namespace: string | |
parentTestsFolder: string | |
parentTestsFolderDisplay: string | |
projectName: string | |
projectRoot: string | |
proxyUrl: string | |
remote: RemoteState | |
report: boolean | |
reporterRoute: string | |
reporterUrl: string | |
socketId: null | string | |
socketIoCookie: string | |
socketIoRoute: string | |
spec: Cypress['spec'] | null | |
specs: Array<Cypress['spec']> | |
xhrRoute: string | |
xhrUrl: string | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tgriesser Setting these on packages/app/cypress.config.ts doesn't seem to be early enough for parent cypress
Edit: The above comment is with respect to setting an environment variable in the cypress config file. I imagine if we add a first class internal config this will work.
This reverts commit 8a25ab2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great - as pointed out there's a few things we might be able to improve upon around the sockets & env variables needing to be passed by the CLI, but overall I think it's good to merging and iterate from here
User facing changelog
N/A
Additional details
From the list of items on the parent issue, the ones done with this PR are crossed off. The ones not will be handled by separate PRs, but with this change it should unblock people from writing tests
Namespacing
General routes need to be namespacedWe will ensure that we are both utilizing the namespace on the client and factoring in the namespace in our route handling on the serverCurrently the config is being retrieved via a call to the server. This will prevent the child Cypress instance config from being able to be loaded properly on the client since it doesn't know to namespace the API call yet. We will fix this by rendering the cypress config to the initial page server side in a global variable that can then be utilized client side to access the config.We will ensure that we are using the config.socketIoRoute as the path wherever we are creating a websocketOther Problems
Connecting to an already existing browserSince we already have a browser running when the child cypress server starts, we will need to set up a remote connection. We will do this by using CDPAutomation to attach to the existing browser instead of opening a new browser instance when we are in cypress in cypress. In order to facilitate this we are going to launch cypress in cypress tests with the environment variable set that specifies the remote debugging port. Also we are focused only on chromeHow has the user experience changed?
N/A
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?