mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-02 21:10:47 -05:00
add sinon stub types to window alert and confirm (#3452)
This commit is contained in:
Vendored
+3
-3
@@ -3852,7 +3852,7 @@ declare namespace Cypress {
|
||||
})
|
||||
```
|
||||
*/
|
||||
(action: 'window:confirm', fn: ((text: string) => false | void) | Agent<sinon.SinonSpy>): void
|
||||
(action: 'window:confirm', fn: ((text: string) => false | void) | Agent<sinon.SinonSpy> | Agent<sinon.SinonStub>): void
|
||||
/**
|
||||
* Fires when your app calls the global `window.alert()` method.
|
||||
* Cypress will auto accept alerts. You cannot change this behavior.
|
||||
@@ -3869,7 +3869,7 @@ declare namespace Cypress {
|
||||
```
|
||||
* @see https://on.cypress.io/catalog-of-events#App-Events
|
||||
*/
|
||||
(action: 'window:alert', fn: ((text: string) => void) | Agent<sinon.SinonSpy>): void
|
||||
(action: 'window:alert', fn: ((text: string) => void) | Agent<sinon.SinonSpy> | Agent<sinon.SinonStub>): void
|
||||
/**
|
||||
* Fires as the page begins to load, but before any of your applications JavaScript has executed. This fires at the exact same time as `cy.visit()` `onBeforeLoad` callback. Useful to modify the window on a page transition.
|
||||
* @see https://on.cypress.io/catalog-of-events#App-Events
|
||||
@@ -4081,7 +4081,7 @@ declare namespace Cypress {
|
||||
}
|
||||
|
||||
// Diff taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
|
||||
type Diff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T]
|
||||
type Diff<T extends string, U extends string> = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
||||
}
|
||||
|
||||
|
||||
@@ -45,14 +45,20 @@ Cypress.browser // $ExpectType Browser
|
||||
|
||||
// stubbing window.alert type on "Cypress" should
|
||||
// work with plain function or with a Sinon stub
|
||||
Cypress.on('window:alert', () => {})
|
||||
Cypress.on('window:alert', () => { })
|
||||
Cypress.on('window:alert', cy.spy())
|
||||
Cypress.on('window:alert', cy.stub())
|
||||
// same for a single test
|
||||
cy.on('window:alert', () => {})
|
||||
cy.on('window:alert', () => { })
|
||||
cy.on('window:alert', cy.spy())
|
||||
cy.on('window:alert', cy.stub())
|
||||
|
||||
// window:confirm stubbing
|
||||
cy.on('window:confirm', () => {})
|
||||
Cypress.on('window:confirm', () => { })
|
||||
Cypress.on('window:confirm', cy.spy())
|
||||
Cypress.on('window:confirm', cy.stub())
|
||||
cy.on('window:confirm', () => { })
|
||||
cy.on('window:confirm', cy.spy())
|
||||
cy.on('window:confirm', cy.stub())
|
||||
|
||||
// specifying HTTP method directly in the options object
|
||||
@@ -90,6 +96,6 @@ const opts2 = {
|
||||
cy.request(opts2)
|
||||
|
||||
const obj = {
|
||||
foo: () => {}
|
||||
foo: () => { }
|
||||
}
|
||||
cy.spy(obj, 'foo').as('my-spy')
|
||||
|
||||
Reference in New Issue
Block a user