-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
misc.ts
26 lines (21 loc) · 886 Bytes
/
misc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import type { $Cy } from '../../cypress/cy'
export const handleMiscEvents = (Cypress: Cypress.Cypress, cy: $Cy) => {
Cypress.on('viewport:changed', (viewport, callbackFn) => {
Cypress.specBridgeCommunicator.once('viewport:changed:end', () => {
callbackFn()
})
Cypress.specBridgeCommunicator.toPrimary('viewport:changed', viewport)
})
Cypress.specBridgeCommunicator.on('sync:state', (state) => {
cy.state(state)
})
// Forward url:changed Message to the primary origin to enable changing the url displayed in the AUT
// @ts-ignore
Cypress.on('url:changed', (url) => {
Cypress.specBridgeCommunicator.toPrimary('url:changed', { url })
})
// Listen for any unload events in other origins, if any have unloaded we should also become unstable.
Cypress.specBridgeCommunicator.on('before:unload', () => {
cy.state('isStable', false)
})
}