Im trying out cypress component test in React and Im kinda confused on some basic stuff like how to assert click handlers.
In Jest I can do something like
const hideMock = jest.fn();
renderWithProviders(
<EmployeeCreationWizard
hide={hideMock}
isVisible={true}
employeeId={123}
/>,
);
await cancel();
expect(hideMock).toBeCalledTimes(1);
How can I do the const hideMock = jest.fn();
with cypress spies?
This is what I got
it.only('invoke hide() once upon clicking on cancel button', () => {
const hideSpy = cy.spy();
cy.interceptEmployeeCreationWizard();
cy.mount(
<EmployeeCreationWizard
isVisible={true}
hide={hideSpy}
employeeId={123}
/>,
);
cy.findByTestId('employee-wizard-drawer-cancel').click();
cy.get('[data-test-id="employee-wizard-drawer-close"]').click();
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
// expect(hideSpy).to.be.calledOnce;
});