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: improve handling of userland injected styles in component testing #16024

Merged
merged 8 commits into from Apr 21, 2021

Conversation

lmiller1990
Copy link
Contributor

@lmiller1990 lmiller1990 commented Apr 16, 2021

User facing changelog

Injected styles via styled components get cleaned up after each spec.

Additional details

We no longer clean up <head>. This is more in line with what users expect. If they are using a library like styled-components, which injects stylesheets into <head>, those will be persisted between tests. We do clean up stylesheets injected via the mount options.

I also added a @cypress/mount-utils package. Now the style injecting/clean up is consistent between both Vue and React. Furthermore, now Vue and React both have the same mounting options for styles. This was not the case previously - due to copy-pasting, they were mostly the same, but not quite. This package will be useful moving forward for other adapters, like Angular, which is discussed here.

NOTE: These changes will need to be ported to the Vue 3 branch, too. I guess we just do that as soon as this is merged into master and the @cypress/mount-utils package is published on npm.

How has the user experience changed?

Userland styles are not nuked between tests. Subsequent tests are able to retain and use the injected styles.

PR Tasks

  • Have tests been added/updated?
  • Has the original issue or this PR been tagged with a release in ZenHub?
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 16, 2021

Thanks for taking the time to open a PR!

@lmiller1990 lmiller1990 changed the base branch from develop to master April 16, 2021 05:19
@cypress
Copy link

cypress bot commented Apr 16, 2021



Test summary

8039 0 101 3Flakiness 0


Run details

Project cypress
Status Passed
Commit 03627ef
Started Apr 20, 2021 8:08 PM
Ended Apr 20, 2021 8:20 PM
Duration 11:45 💡
OS Linux Debian - 10.8
Browser Multiple

View run in Cypress Dashboard ➡️


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

agg23
agg23 previously approved these changes Apr 16, 2021
npm/mount-utils/src/index.ts Show resolved Hide resolved
@lmiller1990 lmiller1990 merged commit fe0b63c into master Apr 21, 2021
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.

styles are only loaded for first component test if styled-components is used
4 participants