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: cy.contains does not return <body> when the finding text is in <script> or <style> #15574

Closed
wants to merge 1 commit into from

Conversation

sainthkh
Copy link
Contributor

@sainthkh sainthkh commented Mar 19, 2021

User facing changelog

cy.contains does not return <body> when the finding text is in <script> or <style>.

Additional details

  • Why was this change necessary? => cy.contains should return "element not found" even if the finding text is in <script> or <style> tags.
  • What is affected by this change? => Please check the note "Is this a breaking change?" below.
  • Any implementation details to explain? => Added "body" to the ":not" list.

Is this a breaking change?

In some tests like below,

it('will not find script elements', () => {
cy.$$('<script>// some-script-content </script>').appendTo(cy.$$('body'))
cy.contains('some-script-content').should('not.match', 'script')
})

the test fails after this change, because cy.contains() does not return any element.

Should we call this behavior a bug or a breaking change?

How has the user experience changed?

N/A

PR Tasks

  • Have tests been added/updated?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 19, 2021

Thanks for taking the time to open a PR!

@sainthkh sainthkh closed this Mar 22, 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.

cy.contains('xxx').should('not.exist') try to expect <body> not to exist in the DOM
1 participant