mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-26 00:49:05 -06:00
Added missing EventEmitter2 type to Cypress and cy + missing ru… (#6066)
* Added EventEmitter2 type to Cypress and cy. * Added missing runUrl * runUrl is optional * Fixed typo. Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
This commit is contained in:
committed by
Gleb Bahmutov
parent
16deee4145
commit
11bd06b6ee
@@ -37,6 +37,7 @@
|
||||
"commander": "2.15.1",
|
||||
"common-tags": "1.8.0",
|
||||
"debug": "3.2.6",
|
||||
"eventemitter2": "4.1.2",
|
||||
"execa": "0.10.0",
|
||||
"executable": "4.1.1",
|
||||
"extract-zip": "1.6.7",
|
||||
|
||||
5
cli/types/cypress-npm-api.d.ts
vendored
5
cli/types/cypress-npm-api.d.ts
vendored
@@ -461,6 +461,11 @@ declare module 'cypress' {
|
||||
totalPassed: number
|
||||
totalPending: number
|
||||
totalSkipped: number
|
||||
/**
|
||||
* If Cypress test run is being recorded, full url will be provided.
|
||||
* @see https://on.cypress.io/dashboard-introduction
|
||||
*/
|
||||
runUrl?: string
|
||||
runs: RunResult[]
|
||||
browserPath: string
|
||||
browserName: string
|
||||
|
||||
13
cli/types/index.d.ts
vendored
13
cli/types/index.d.ts
vendored
@@ -30,6 +30,15 @@
|
||||
// hmm, how to load it better?
|
||||
/// <reference path="./cypress-npm-api.d.ts" />
|
||||
|
||||
// Cypress, cy, Log inherits EventEmitter.
|
||||
type EventEmitter2 = import("eventemitter2").EventEmitter2
|
||||
|
||||
interface EventEmitter extends EventEmitter2 {
|
||||
proxyTo: (cy: Cypress.cy) => null
|
||||
emitMap: (eventName: string, args: any[]) => Array<(...args: any[]) => any>
|
||||
emitThen: (eventName: string, args: any[]) => Bluebird.BluebirdStatic
|
||||
}
|
||||
|
||||
// Cypress adds chai expect and assert to global
|
||||
declare const expect: Chai.ExpectStatic
|
||||
declare const assert: Chai.AssertStatic
|
||||
@@ -4506,7 +4515,7 @@ cy.get('button').click()
|
||||
cy.get('.result').contains('Expected text')
|
||||
```
|
||||
*/
|
||||
declare const cy: Cypress.cy
|
||||
declare const cy: Cypress.cy & EventEmitter
|
||||
|
||||
/**
|
||||
* Global variable `Cypress` holds common utilities and constants.
|
||||
@@ -4518,4 +4527,4 @@ Cypress.version // => "1.4.0"
|
||||
Cypress._ // => Lodash _
|
||||
```
|
||||
*/
|
||||
declare const Cypress: Cypress.Cypress
|
||||
declare const Cypress: Cypress.Cypress & EventEmitter
|
||||
|
||||
@@ -11,6 +11,7 @@ cypress.run().then(results => {
|
||||
results // $ExpectType CypressRunResult
|
||||
results.failures // $ExpectType number | undefined
|
||||
results.message // $ExpectType string | undefined
|
||||
results.runUrl // $ExpectType string | undefined
|
||||
})
|
||||
cypress.open() // $ExpectType Promise<void>
|
||||
cypress.run() // $ExpectType Promise<CypressRunResult>
|
||||
|
||||
@@ -63,13 +63,20 @@ stub()
|
||||
expect(stub).to.have.been.calledOnce
|
||||
cy.wrap(stub).should('have.been.calledOnce')
|
||||
|
||||
// window:confirm stubbing
|
||||
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())
|
||||
namespace EventInterfaceTests {
|
||||
// window:confirm stubbing
|
||||
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())
|
||||
|
||||
Cypress.removeListener('fail', () => {})
|
||||
Cypress.removeAllListeners('fail')
|
||||
cy.removeListener('fail', () => {})
|
||||
cy.removeAllListeners('fail')
|
||||
}
|
||||
|
||||
// specifying HTTP method directly in the options object
|
||||
cy.request({
|
||||
|
||||
Reference in New Issue
Block a user