Looking for a test like below. Basically I get it to work using cy.get('@myLog').should('be.called') but I’m trying to test the value console log is using when called. In jest it would be toHaveBeenCalledWith() so the equivalent in cypress is what I’m after ?
cy.window().then((win) => {
cy.wrap(cy.spy(win.console, 'log')).as('myLog')
})
cy.get('@myLog')
.should('be.called')
.and('have.value', 'clicked')
>Solution :
cy.spy() and cy.stub() you can use Sinon-chai assertions. So for you instance you may want to use be.calledWith.
cy.window().then((win) => {
cy.wrap(cy.spy(win.console, 'log')).as('myLog')
})
cy.get('@myLog')
.should('be.calledWith', 'clicked')