Skip to content

Commit

Permalink
fix: Fix Typescript types for screenshot command. (#27130)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Plummer <[email protected]>
Co-authored-by: Mike Plummer <[email protected]>
  • Loading branch information
3 people committed Jul 7, 2023
1 parent 213afde commit d56b628
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
## 12.17.1

_Released 07/18/2023 (PENDING)_

**Bugfixes:**

- Fixed an issue with the Typescript types of [`cy.screenshot()`](https://docs.cypress.io/api/commands/screenshot). Fixed in [#27130](https://github.com/cypress-io/cypress/pull/27130).

## 12.17.0

_Released 07/05/2023_
Expand Down
6 changes: 4 additions & 2 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1901,15 +1901,17 @@ declare namespace Cypress {
* cy.screenshot()
* cy.get(".post").screenshot()
*/
screenshot(options?: Partial<Loggable & Timeoutable & ScreenshotOptions>): Chainable<null>
screenshot(options?: Partial<Loggable & Timeoutable & ScreenshotOptions>): Chainable<Subject>

/**
* Take a screenshot of the application under test and the Cypress Command Log and save under given filename.
*
* @see https://on.cypress.io/screenshot
* @example
* cy.screenshot("post-element")
* cy.get(".post").screenshot("post-element")
*/
screenshot(fileName: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions>): Chainable<null>
screenshot(fileName: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions>): Chainable<Subject>

/**
* Scroll an element into view.
Expand Down
12 changes: 12 additions & 0 deletions cli/types/tests/cypress-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ namespace CypressCommandsTests {

return originalFn(element, text, options)
})
Cypress.Commands.overwrite<'screenshot', 'element'>('screenshot', (originalFn, subject, fileName, options) => {
subject // $ExpectType JQueryWithSelector<HTMLElement>
fileName // $ExpectType string
options // $ExpectType Partial<Loggable & Timeoutable & ScreenshotOptions> | undefined
})

Cypress.Commands.addQuery('newQuery', function(arg) {
this // $ExpectType Command
Expand Down Expand Up @@ -661,6 +666,9 @@ namespace CypressFilterTests {
}

namespace CypressScreenshotTests {
cy.screenshot().then((result) => {
result // $ExpectType undefined
})
cy.screenshot('example-name')
cy.screenshot('example', { log: false })
cy.screenshot({ log: false })
Expand All @@ -672,6 +680,10 @@ namespace CypressScreenshotTests {
log: true,
blackout: []
})
cy.get<HTMLDivElement>('#id').screenshot('example-name', { log: false })
cy.get<HTMLDivElement>('#id').screenshot().then((result) => {
result // $ExpectType JQuery<HTMLDivElement>
})
}

namespace CypressShadowDomTests {
Expand Down

5 comments on commit d56b628

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d56b628 Jul 7, 2023

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.1/linux-arm64/develop-d56b628b30f432c74661e8233bcca93de8421564/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d56b628 Jul 7, 2023

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.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.1/linux-x64/develop-d56b628b30f432c74661e8233bcca93de8421564/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d56b628 Jul 7, 2023

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.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.1/darwin-x64/develop-d56b628b30f432c74661e8233bcca93de8421564/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d56b628 Jul 7, 2023

Choose a reason for hiding this comment

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

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

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.1/win32-x64/develop-d56b628b30f432c74661e8233bcca93de8421564/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d56b628 Jul 7, 2023

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.1/darwin-arm64/develop-d56b628b30f432c74661e8233bcca93de8421564/cypress.tgz

Please sign in to comment.