Created
January 21, 2022 23:08
-
-
Save adamdehaven/aba81d5951c931c44260212e98c69bde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cy.get('.button').click().then(() => { | |
cy.wrap(Cypress.vueWrapper.emitted()).should('have.property', 'click-forgot-password-link') | |
}) |
Vuetify's next
branch has a bunch of Cypress component testing examples. Button. They use TSX but you can do something like this:
const onRegister = cy.stub()
mount(KongAuthRegister, {
props: {
onRegisterSuccess: onRegister
}
})
cy.intercept('POST', '**/register', {
body: {
organizationID: '187e2b65-ec69-421c-a7ba-3e946c4e5077',
},
}).as('register-request')
// stuff ...
cy.wait('@register-request').its('response.body').should('have.property', 'organizationID').then(() => {
// Check for emitted event
expect(onRegister).to.have.been.calledWith(......) // <================== your object here??
})
The trick is Vue turns @register-success
into an onRegisterSuccess
props when it compiles.
Example: lmiller1990/vue-3-cypress-vite#2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How would you access the emitted event (and it’s payload) instead?