cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.66k stars 3.16k forks source link

Passing an object to 'css', 'prop', or 'attr' assertions always passes #7353

Closed panzarino closed 1 month ago

panzarino commented 4 years ago

Current behavior:

Passing an object as the first parameter to the 'css, prop, or attr assertions will always pass, regardless of the element's actual properties.

Desired behavior:

There are two possible courses of action here:

It appears that the second course of action is preferred, as it will make it simpler when performing multiple assertions and be more consistent with how a developer may expect it to function.

Test code to reproduce

this.$div = $('<div style=\'display: none\'>div</div>')

// all will pass
expect(this.$div).to.have.css({ display: 'none' })
expect(this.$div).to.have.css({ display: 'inline' })
expect(this.$div).to.have.css({ foo: 'bar' })

// all will fail
expect(this.$div).not.to.have.css({ display: 'none' })
expect(this.$div).not.to.have.css({ display: 'inline' })
expect(this.$div).not.to.have.css({ foo: 'bar' })

This same behavior can be observed with prop and attr.

Versions

4.5.0

cypress-app-bot commented 1 month ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot commented 1 month ago

This issue has been closed due to inactivity.