Skip to content
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

moved to #27911 #27150

Closed
wants to merge 99 commits into from
Closed

moved to #27911 #27150

wants to merge 99 commits into from

Conversation

alexsch01
Copy link
Contributor

@alexsch01 alexsch01 commented Jun 27, 2023

moved to #27911

@cypress-app-bot
Copy link
Collaborator

@mike-plummer mike-plummer self-assigned this Jun 27, 2023
@mike-plummer
Copy link
Contributor

Hi @alexsch01 , thanks for the contribution!

I believe there is already a documented pattern for situations where you have a test suite designed to only run against Chrome instead of Electron - does this recipe meet your needs? Is there a use case that this new param would solve not already addressable by that pattern?

@alexsch01
Copy link
Contributor Author

alexsch01 commented Jun 27, 2023

@mike-plummer

that's only for "cypress open", my PR is used for both "cypress open" and "cypress run


This pull request is ready for review now

Please ask any questions that you have with this PR

Copy link
Contributor

@mike-plummer mike-plummer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @alexsch01

This feels more like a defaultBrowser flag to me since it only applies if the user doesn't supply a --browser flag themselves.

A better location for this logic may be packages/data-context/src/data/ProjectLifecycleManager.ts#setInitialActiveBrowser. The approach you're using here while effective would also end up setting config flags like cliBrowser which tell other places in Cypress that the user specified an override of the browser via the CLI which isn't really the case. The code I referenced already has certain fallback cases to determine the most appropriate browser to launch based on things like:

  • Is a CLI flag passed?
  • If not, what was the last browser the project used?
  • If that's not available, is there a good default we can choose?

In addition, there will need to be some tests written for this, both in the data-context package (assuming that ends up being a good place for this live) as well as system tests to validate that Cypress actually launches as expected with that new flag. The sometimes annoying part of developing a testing tool is that the tests end up being way bigger than the feature 😆

Finally, this will need corresponding updates in cypress-documentation, but that can wait until an implementation settles

@alexsch01
Copy link
Contributor Author

Changed browser to defaultBrowser and I agree that defaultBrowser is the more appropriate name since it only takes effect if there is no "--browser" passed by the user in the CLI

Also, added the defaultBrowser type to the cypress.d.ts file

@alexsch01
Copy link
Contributor Author

alexsch01 commented Jun 27, 2023

Documentation is done

I have manually tested that this change does work successfully

@alexsch01 alexsch01 requested a review from mike-plummer June 28, 2023 01:15
@alexsch01
Copy link
Contributor Author

alexsch01 commented Jun 28, 2023

@mike-plummer

Currently the way I'm reading the config object is converting the cypress config file as an object which allows me to get the defaultBrowser attribute

Is there a way of reading the config object more directly?

@mike-plummer
Copy link
Contributor

@alexsch01 I left comments yesterday around the fact that this logic may have unintended side-effects and would likely belong elsewhere. Have you reviewed and considered that suggestion?

We ask that contributors at least attempt to write tests for their PRs - we're happy to answer questions or assist if you get stuck

@alexsch01
Copy link
Contributor Author

@mike-plummer I read your suggestion......I'm still unsure how to read the cypress config object

@mike-plummer
Copy link
Contributor

@mike-plummer I read your suggestion......I'm still unsure how to read the cypress config object

From within data-context you can retrieve the effective project configuration via this.ctx.project.getConfig()

@alexsch01
Copy link
Contributor Author

I put a final commit before I look into the entirely different method

@alexsch01
Copy link
Contributor Author

@mike-plummer

The reason I put the changes under node_modules\cypress\lib\cli.js was so that I can test the changes with my cypress project without compiling Cypress from source

What unintended side-effects do you see from this code change?

@mike-plummer
Copy link
Contributor

@alexsch01 From my earlier review

The approach you're using here while effective would also end up setting config flags like cliBrowser which tell other places in Cypress that the user specified an override of the browser via the CLI which isn't really the case.

There are instructions in the CONTRIBUTING guide for how to run cypress locally - are you having trouble getting the app running in development mode?

@mike-plummer
Copy link
Contributor

mike-plummer commented Jun 28, 2023

@jennifer-shehane @brian-mann Would appreciate any thoughts y'all have on this. I can see the potential value to change the default browser from "electron", but existing functionality to control this already exists via the CLI --browser flag if you set up dedicated Node script aliases

@alexsch01
Copy link
Contributor Author

@lmiller1990 please allow the build to run

@lmiller1990
Copy link
Contributor

@alexsch01 I'm not working at Cypress now, I can't trigger the build. Maybe @jennifer-shehane can do that for you.

@jennifer-shehane
Copy link
Member

@alexsch01 Pulled in develop

@jennifer-shehane jennifer-shehane removed the request for review from lmiller1990 September 13, 2023 14:35
@alexsch01
Copy link
Contributor Author

@jennifer-shehane please assign this to someone

@jennifer-shehane
Copy link
Member

Hi @alexsch01, we don't have anyone available currently to spend the time to review this change.

* Update cypress.d.ts

* Update specs.cy.ts

* Update specs.cy.ts

* Update index.ts

* Update index.spec.ts.js

* Update options.ts

* Update index.spec.ts

* Update utils.spec.ts

* oops

* Update ProjectLifecycleManager.ts

* Update config-warning.cy.ts

* Update open-mode.cy.ts

* Update index.ts

* Update project-base.ts

* Update config.ts

* Update results_spec.ts.js

* Update cypress.config.js

* Update cypress.config.js
@alexsch01 alexsch01 changed the title feat: ability to specify the default running browser in cypress configuration file feat: ability to specify the default browser in cypress configuration file Sep 22, 2023
@alexsch01 alexsch01 changed the title feat: ability to specify the default browser in cypress configuration file feat: ability to specify the default browser in cypress config file Sep 22, 2023
@alexsch01 alexsch01 closed this Sep 26, 2023
@alexsch01
Copy link
Contributor Author

moved to #27911

@alexsch01 alexsch01 mentioned this pull request Sep 26, 2023
@alexsch01 alexsch01 changed the title feat: ability to specify the default browser in cypress config file (OLD) feat: ability to specify the default browser in cypress config file Sep 26, 2023
@alexsch01 alexsch01 changed the title (OLD) feat: ability to specify the default browser in cypress config file (OLD) https://github.com/cypress-io/cypress/pull/27911 Sep 26, 2023
@alexsch01 alexsch01 changed the title (OLD) https://github.com/cypress-io/cypress/pull/27911 moved to #27911 Sep 26, 2023
@alexsch01 alexsch01 deleted the default-browser-config branch September 26, 2023 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants