1

The following:

cy.get( '@bar' ).
  its( 'clientHeight' ).
    should( 'eq', '300px' );

Fails with this CypressError:

Timed out retrying: cy.its() errored because the property: clientHeight does not exist on your subject.

cy.its() waited for the specified property clientHeight to exist, but it never did.

The browser supports Element.clientHeight because I use it in the code, and other assertions on the same alias correctly pass.

Thanks in advance for any suggestions!

Andrew M. Andrews III
  • 1,989
  • 18
  • 23

1 Answers1

0

Cypress command cy.get() yields a jquery object referencing a DOM element or a collection of DOM elements. You can find a good explanation of the difference at: jQuery object and DOM element

The way to get to the clientHeight property would be to accessed the DOM element from the yielded jquery object by using the get(index) method:

cy.get('@bar').should($bar => {
    expect($bar.get(0)).to.have.property('clientHeight', '300px');
});
PeaceAndQuiet
  • 1,692
  • 8
  • 13