Skip to content

Commit

Permalink
TypeScript: strict parameter type for location (#5574)
Browse files Browse the repository at this point in the history
* TypeScript: strict parameter type for `location`

* extend Location, return correct type

* add type tests


Co-authored-by: Zach Bloomquist <github@chary.us>
  • Loading branch information
OliverJAsh and flotwig committed Dec 19, 2019
1 parent 720bc47 commit 78d0536
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ declare namespace Cypress {
* // Assert on the href of the location
* cy.location('href').should('contain', '/tag/tutorials')
*/
location(key: string, options?: Partial<Loggable & Timeoutable>): Chainable<Location>
location<K extends keyof Location>(key: K, options?: Partial<Loggable & Timeoutable>): Chainable<Location[K]>

/**
* Print a message to the Cypress Command Log.
Expand Down
6 changes: 6 additions & 0 deletions cli/types/tests/cypress-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,9 @@ namespace CypressContainsTests {
cy.contains('#app', 'my text to find', {log: false, timeout: 100})
cy.contains('my text to find', {log: false, timeout: 100})
}

// https://github.com/cypress-io/cypress/pull/5574
namespace CypressLocationTests {
cy.location('path') // $ExpectError
cy.location('pathname') // $ExpectType Chainable<string>
}

4 comments on commit 78d0536

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 78d0536 Dec 19, 2019

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.1/linux-x64/circle-develop-78d0536109f8717c4a3889a1c4438878a94a73ee-219835/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.1/circle-develop-78d0536109f8717c4a3889a1c4438878a94a73ee-219795/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 78d0536 Dec 19, 2019

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.1/win32-ia32/appveyor-develop-78d0536109f8717c4a3889a1c4438878a94a73ee-29657486/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.8.1/win32-ia32/appveyor-develop-78d0536109f8717c4a3889a1c4438878a94a73ee-29657486/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 78d0536 Dec 19, 2019

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.1/win32-x64/appveyor-develop-78d0536109f8717c4a3889a1c4438878a94a73ee-29657486/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.8.1/win32-x64/appveyor-develop-78d0536109f8717c4a3889a1c4438878a94a73ee-29657486/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 78d0536 Dec 19, 2019

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.1/darwin-x64/circle-develop-78d0536109f8717c4a3889a1c4438878a94a73ee-219881/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.1/circle-develop-78d0536109f8717c4a3889a1c4438878a94a73ee-219763/cypress.tgz

Please sign in to comment.