Skip to content

Conversation

@ZachJW34
Copy link
Contributor

User facing changelog

Lift indexHtmlFile up to component config and validate the property is only valid on the component config.

Additional details

The PR is broken up into two commits, the first contains the logic for lifting the property and adding validation and the second adds the missing component-index.html file to projects that were relying on the default (hopefully makes it easier to review). There is no longer a fallback template for @cypress/webpack-dev-server and @cypress/vite-dev-server since we are scaffolding this file to the users project at cypress/support/component-index.html which will be the default value of component.indexHtmlFile.

There is validation of the indexHtmlFile property to ensure that it is not added at the root level of the config or in the e2e config. All devServers have been updated to pull this value from the cypress config rather than passing the option explicitly.

I did not implement the getTemplate API outlined in the issue as that is an implementation detail that should be implemented after the Object API is merged, I will update the ticket and create another one to implement it. We already have this logic inside of WizardActions, it's just not ideal but we can move forward without it.

The removal of the template property from @cypress/webpack-dev-server is a breaking change but we already plan on making breaking changes to the dev-servers. These changes won't be released until 10.0 and there is an issue for ensuring 9.x users don't use the 10.0 supported version. This property was mostly an internal property and not documented.

How has the user experience changed?

User no longer needs to specify indexHtmlFile in their config as config.component.indexHtmlFile will have a default value of cypress/support/component-index.html which is scaffolded for them during project setup.

Before:

module.exports = {
  component: {
  	devServer,
	devServerConfig: {
	  indexHtmlFile: 'cypress/support/component-index.html',
	},
  },
} 

After:

module.exports = {
  component: {
  	devServer,
  },
}

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? Notion is up to date
  • Have API changes been updated in the type definitions?
  • [NA] Have new configuration options been added to the cypress.schema.json?

@ZachJW34 ZachJW34 requested review from a team as code owners March 31, 2022 16:20
@ZachJW34 ZachJW34 requested review from jennifer-shehane and removed request for a team March 31, 2022 16:20
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 31, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Mar 31, 2022



Test summary

17792 0 217 0Flakiness 1


Run details

Project cypress
Status Passed
Commit c8e737a
Started Apr 1, 2022 2:09 PM
Ended Apr 1, 2022 2:22 PM
Duration 12:49 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

cypress/e2e/cypress/source_map_utils.cy.js Flakiness
1 driver/src/cypress/source_map_utils > .extractSourceMap > is performant with multiple source map comments in file

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

@jennifer-shehane jennifer-shehane removed their request for review March 31, 2022 17:29
* @default {}
*/
e2e: CoreConfigOptions
e2e: Omit<CoreConfigOptions, 'indexHtmlFile'>
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we want this on CoreConfigOptions rather than ComponentConfigOptions?

Copy link
Contributor Author

@ZachJW34 ZachJW34 Mar 31, 2022

Choose a reason for hiding this comment

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

My understanding is that, once the config is resolved, you should access the properties as root level properties since testingType specific options are merged to be top-level. So inside of startServer.ts for webpack, you should be able to do config.indexHtmlFile rather than config.component.indexHtmlFile (the config passed into the devServer doesn't even have a component object so you can't do config.component.indexHtmlFile).

The options in ComponentConfigOptions aren't typed at the root level, so if I wanted to define them there we would have to refactor those types.

Copy link
Member

Choose a reason for hiding this comment

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

I think for the devServer we're generally going to be accessing the properties off of the un-merged config anyway, because the merging happens in the parent process and we can't serialize/unserialize a user's webpackConfig over the wire (ran into that when refactoring the object API)

The options in ComponentConfigOptions aren't typed at the root level,

Might not be sure what you're referring to - I was just saying to add the type to this interface:

interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl'> {
    devServer: DevServerFn<ComponentDevServerOpts>
    devServerConfig?: ComponentDevServerOpts
}

And then use it from that to pass into startServer directly

Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

@ZachJW34 nice - this all seems pretty straight forward, since getTemplateHtml isn't implemented, and we are just lifting the indexHtmlFile up

If we are going to do the getTemplateHtml changes separately, I think we should:

  1. Update the Jira ticket to reflect the actual work done here (right now based on Jira, it looks like everything should be here, which it's not)
  2. Create a new ticket with the remaining work to be done

What do you think?

Not sure what's going on with Percy, 💀

@tgriesser tgriesser self-requested a review April 1, 2022 13:12
@ZachJW34
Copy link
Contributor Author

ZachJW34 commented Apr 1, 2022

@lmiller1990 I'll update the issue now, was just going to wait a bit to see how the PR shakes out.

Updated and created a new issue. Merged latest master and the crazy Percy diffs went away.

@ZachJW34 ZachJW34 merged commit 2c8e97d into 10.0-release Apr 1, 2022
@ZachJW34 ZachJW34 deleted the zachw/component-index-html-lift branch April 1, 2022 14:45
tgriesser added a commit that referenced this pull request Apr 1, 2022
* 10.0-release:
  fix: add index.mjs to the published files of cli (#20884)
  refactor: lift indexHtmlFile up to component, add validation (#20870)
  fix: allow migration of pluginsFile using `env` properties (#20770)
  fix: viewport from CLI on CT (#20849)
  fix: git data source unit test failure (#20875)
  fix: Ensuring current browser is synchronized between app and launchpad (#20830)
  Fix missed await on merge conflict resolution
  test(unification): move record keys to contexts (#20860)
  test: move record keys to contexts (#20859)
  make alerts more responsive
  chore: Update Chrome (stable) to 100.0.4896.60 (#20841)
  Revise test.
  fix: cy.root respect timeout option.
  fix(deps): update dependency ansi-regex to v4.1.1 [security] (#20836)
  chore(deps): update dependency ansi-regex to 4.1.1 [security] (#20807)
  chore: Refactor cri-client to use async/await (#20825)
  remove automationId from runnerStore
  fix firefox automation and adress feedback
  feat: add automation warning/disconnected states in app
tgriesser added a commit that referenced this pull request Apr 1, 2022
…ess into tgriesser/fix/UNIFY-1389

* 'tgriesser/fix/UNIFY-1389' of github.com:cypress-io/cypress: (56 commits)
  fix: add index.mjs to the published files of cli (#20884)
  refactor: lift indexHtmlFile up to component, add validation (#20870)
  fix: allow migration of pluginsFile using `env` properties (#20770)
  fix: viewport from CLI on CT (#20849)
  Don't communicate if process isn't connected
  Remove config.get
  Update packages/data-context/src/data/ProjectLifecycleManager.ts
  fix: git data source unit test failure (#20875)
  add comment for autoBindDebug
  PR comments
  Fix tests that visit app without a configured testing type
  Fix type script
  Fix issue with refreshing on the welcome screen
  Add test for migration scenario
  Fix types
  Move IPC logic to all be in ProjectConfigIPC
  Other minor cleanup
  Additional code cleanup
  Fix more tests
  Fix typo
  ...
tgriesser added a commit that referenced this pull request Apr 5, 2022
* 10.0-release: (92 commits)
  chore: remove dependency-tree dep (#20905)
  chore(launchpad): work on infra for scaffold tests (#20818)
  fix: build mjs in the cli (#20889)
  fix(unify): Cypress version link should point to Cypress doc's changelog (#20869)
  fix: windows build (#20854)
  fix: add index.mjs to the published files of cli (#20884)
  refactor: lift indexHtmlFile up to component, add validation (#20870)
  fix: allow migration of pluginsFile using `env` properties (#20770)
  fix: viewport from CLI on CT (#20849)
  Don't communicate if process isn't connected
  Remove config.get
  Update packages/data-context/src/data/ProjectLifecycleManager.ts
  fix: git data source unit test failure (#20875)
  add comment for autoBindDebug
  fix: Ensuring current browser is synchronized between app and launchpad (#20830)
  Fix missed await on merge conflict resolution
  test(unification): move record keys to contexts (#20860)
  test: move record keys to contexts (#20859)
  PR comments
  Fix tests that visit app without a configured testing type
  ...
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.

4 participants