Skip to content

Commit

Permalink
Added missing EventEmitter2 type to Cypress and cy + missing ru… (#6066)
Browse files Browse the repository at this point in the history
* Added EventEmitter2 type to Cypress and cy.

* Added missing runUrl

* runUrl is optional

* Fixed typo.

Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
  • Loading branch information
sainthkh and bahmutov committed Jan 7, 2020
1 parent 16deee4 commit 11bd06b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions cli/types/cypress-npm-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions cli/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -4518,4 +4527,4 @@ Cypress.version // => "1.4.0"
Cypress._ // => Lodash _
```
*/
declare const Cypress: Cypress.Cypress
declare const Cypress: Cypress.Cypress & EventEmitter
1 change: 1 addition & 0 deletions cli/types/tests/cypress-npm-api-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
21 changes: 14 additions & 7 deletions cli/types/tests/kitchen-sink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

4 comments on commit 11bd06b

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 11bd06b Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/linux-x64/circle-develop-11bd06b6eecd18270a79df245f04e3ff18a736bc-227163/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.2/circle-develop-11bd06b6eecd18270a79df245f04e3ff18a736bc-227158/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 11bd06b Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/win32-ia32/appveyor-develop-11bd06b6eecd18270a79df245f04e3ff18a736bc-29949226/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.8.2/win32-ia32/appveyor-develop-11bd06b6eecd18270a79df245f04e3ff18a736bc-29949226/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 11bd06b Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/win32-x64/appveyor-develop-11bd06b6eecd18270a79df245f04e3ff18a736bc-29949226/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.8.2/win32-x64/appveyor-develop-11bd06b6eecd18270a79df245f04e3ff18a736bc-29949226/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 11bd06b Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/darwin-x64/circle-develop-11bd06b6eecd18270a79df245f04e3ff18a736bc-227202/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.2/circle-develop-11bd06b6eecd18270a79df245f04e3ff18a736bc-227200/cypress.tgz

Please sign in to comment.