Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress Testing - Expect input to be empty

Tags:

cypress

I have an text input field that i would like cypress to check if it's empty.

I've tried:

cy.get('[data-cy=inputField]').should('not.have.value');

cy.get('[data-cy=inputField]').should('be.empty');

both tests pass even though even though there is text in the field.

like image 769
David Storm Avatar asked Dec 31 '22 08:12

David Storm


1 Answers

I've found the solution. It works when i expect it to have the value of an empty string.

cy.get('[data-cy=inputField]').should('have.value', '');
like image 138
David Storm Avatar answered Jan 13 '23 11:01

David Storm