See the application in index.html that shows window.confirm
on click
The cypress/integration/spec.js shows various ways the tests can ensure the async assertions finish before the test finishes. The last test shows how to use cypress-expect-n-assertions to automatically wait for declared number of assertions to run before finishing the test.
import { plan } from 'cypress-expect-n-assertions'
it('waits for planned number of assertion to run', () => {
plan(1)
cy.visit('index.html')
cy.on('window:confirm', (message) => {
expect(message).to.equal('Are you sure?')
})
cy.get('#click').click()
})