Below is the code snippet provided. The code fetches all classes and then checks for the presence of the 'mat-checked' class.
pmanage.no_additional_cost().last().invoke('prop', 'class').then((Class) => {
let Pclass = Class
cy.log(Pclass)
if(Pclass.contains('mat-checked')){
cy.log('mat-checked found')
cy.writeFile(filename, Pclass)
}else{
cy.log('Toggle is off')
}
})