Reputation: 5323
I'm trying to get the value (true or false) of a checked input control
it('Is checkbox checked', () => {
cy.get('mat-checkbox[formcontrolname=favorite]').should('be.checked')
})
But the assertion always fails
Upvotes: 0
Views: 1025
Reputation: 5323
I had to find the native input
it('Is checkbox checked', () => {
cy.get('mat-checkbox[formcontrolname=favorite] input').should('be.checked')
})
Upvotes: 0
Reputation: 2417
You must access the native input
it('Is checkbox checked', () => {
cy
.get('mat-checkbox[formcontrolname=favorite]')
.get('[type="checkbox"]')
.check()
})
Upvotes: 1