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

fix: Issue 23486 #23595

Merged
merged 7 commits into from Aug 29, 2022
Merged

fix: Issue 23486 #23595

merged 7 commits into from Aug 29, 2022

Conversation

amehta265
Copy link
Contributor

User facing changelog

  • When using the Cypress UI, if the dev server is not set up correctly in the cypress config, users should still be able to see list of spec files they can run.

Additional details

  • The error stems from a missing null check for the component.devServer in the config. This could have happened if component testing was partially set up or devServer dependency was removed after the set up.
  • Adding optional chaining to check the existence of the framework on the devServer circumvents the "GraphQL error [GraphQL] Cannot read properties of undefined (reading 'framework')". With optional chaining we will still be checking if the devServer is defined in the framework and if it is undefined it will not throw the error.
  • The cypress-in-cypress.cy.ts test manually changes the config file removing the devServer from the component and then checks if the spec list still shows up.

Steps to test

  1. Go to cypress/packages/data-context/src/actions/ProjectActions.ts. On line 534 remove the '?' character between devServer and framework such that it reads as devServer.framework
  2. Run the cypress-in-cypress.cy.ts test within the app folder of packages.
  3. The 'checks that specs load when devServer configuration is not set in open mode for e2e/CT' test should fail as the spec list is not visible in the DOM.
  4. Repeat step 1 BUT add back the '?' character so it reads as devServer?.framework
  5. Repeat step 2 and the test should pass now.

How has the user experience changed?

Before (When config file does not have a devServer):
Screen Shot 2022-08-29 at 12 12 12 PM

After bug fix:
Screen Shot 2022-08-29 at 12 12 28 PM

PR Tasks

  • Have tests been added/updated?
  • [na] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 29, 2022

Thanks for taking the time to open a PR!

@CLAassistant
Copy link

CLAassistant commented Aug 29, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@marktnoonan marktnoonan left a comment

Choose a reason for hiding this comment

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

Suggested update to the comment but otherwise looks good!

packages/app/cypress/e2e/cypress-in-cypress.cy.ts Outdated Show resolved Hide resolved
@astone123
Copy link
Contributor

Nice! 👍🏻 @marktnoonan should we update the config types? If you look at cypress.d.ts, it looks like devServer is required

  interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl' | 'experimentalSessionAndOrigin' | 'experimentalStudio'> {
    devServer: DevServerFn<ComponentDevServerOpts> | DevServerConfigOptions
    devServerConfig?: ComponentDevServerOpts
    /**
     * Runs all component specs in a single tab, trading spec isolation for faster run mode execution.
     * @default false
     */
    experimentalSingleTabRunMode?: boolean
  }

it seems like it should be optional devServer?: DevServerFn<ComponentDevServerOpts> | DevServerConfigOptions

@cypress
Copy link

cypress bot commented Aug 29, 2022



Test summary

39641 0 3371 0Flakiness 1


Run details

Project cypress
Status Passed
Commit 00d3803
Started Aug 29, 2022 8:12 PM
Ended Aug 29, 2022 8:26 PM
Duration 14:26 💡
OS Linux Debian - 11.3
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

cypress/e2e/commands/waiting.cy.js Flakiness
1 ... > errors > throws when waiting for 2nd response to route

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

@ZachJW34
Copy link
Contributor

@astone123 we shouldn't tweak the devServer types. If they have a component field in the Cypress config, they should have a component.devServer property otherwise they shouldn't have CT configured at all.

@marktnoonan
Copy link
Contributor

The ideal thing to do will be to correctly show a config validation error if devServer is not present. We need a follow up issue for that actually, this just stops the bug.

@astone123 astone123 self-requested a review August 29, 2022 18:51
Copy link
Contributor

@astone123 astone123 left a comment

Choose a reason for hiding this comment

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

Looks good 🎉

packages/data-context/src/actions/ProjectActions.ts Outdated Show resolved Hide resolved
@amehta265 amehta265 merged commit 6a614c3 into develop Aug 29, 2022
@amehta265 amehta265 deleted the issue-23486 branch August 29, 2022 21:04
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.

Cypress UI no longer displays spec files to run
5 participants