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

cy.contains removes <script> and <style> nodes from the app under test #19377

Closed
simfeld opened this issue Dec 15, 2021 · 5 comments · Fixed by #19424
Closed

cy.contains removes <script> and <style> nodes from the app under test #19377

simfeld opened this issue Dec 15, 2021 · 5 comments · Fixed by #19424
Assignees
Labels
type: regression A bug that didn't appear until a specific Cy version release v9.0.0 🐛 Issue present since 9.0

Comments

@simfeld
Copy link
Contributor

simfeld commented Dec 15, 2021

Current behavior

Since version 9.0.0, calling cy.contains removes <script> and <style> nodes from the DOM of the app under test. This is most likely caused by the change in #17477. From the description in the changelog

cy.contains() no longer yields the <body> element when it matches the content of <script> or <style> tags.

I would expect that this only affects the result of the contains command, but leaves the actual DOM unchanged.

Desired behavior

The cy.contains command should not alter the DOM of the application under test as a side effect.

Test code to reproduce

The problem can be reproduced with https://github.com/simfeld/cypress-contains-script. Note that downgrading to 8.7.0 makes these tests pass.

Cypress Version

9.0.0 and later

Other

No response

@tobiasweibel
Copy link

As another drawback of the #17477 change the stack traces of code that is loaded within <body> doesn't make sense anymore. I think I remember that even the browser dev tools aren't working properly after upgrading to Cypress v9 if code was loaded within <body>.

@jennifer-shehane
Copy link
Member

cc @sainthkh

@jennifer-shehane
Copy link
Member

I can confirm the behavior described. The <script> and <style> tags are being removed from the DOM simply by calling cy.contains() on something that is matched within them. This is not intended behavior.

@jennifer-shehane jennifer-shehane added type: regression A bug that didn't appear until a specific Cy version release v9.0.0 🐛 Issue present since 9.0 labels Dec 17, 2021
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: needs review The PR code is done & tested, needs review labels Dec 20, 2021
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Dec 20, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 20, 2021

The code for this is done in cypress-io/cypress#19424, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Dec 20, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 21, 2021

Released in 9.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v9.2.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that didn't appear until a specific Cy version release v9.0.0 🐛 Issue present since 9.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants