← Back to library
Cypressformsbeginnerv10+

Check and uncheck a checkbox

Toggle a checkbox and chain assertions on its state.

1it('checkbox toggles correctly', () => {
2  cy.visit('/preferences');
3
4  cy.get('[name="email-notifications"]')
5    .should('not.be.checked')
6    .check()
7    .should('be.checked')
8    .uncheck()
9    .should('not.be.checked');
10});
#checkbox#check#uncheck#be.checked