Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adding overload to screenshot to fix type errors when overwriting this command. #27130

Merged
merged 13 commits into from
Jul 7, 2023
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ _Released 07/05/2023 (PENDING)_

**Bugfixes:**

- Fixed an issue where type errors are emitted when trying to overwrite the screenshot command. Addressed in [#27130](/~https://github.com/cypress-io/cypress/pull/27130)
- Fixed an issue where some internal file locations consumed by the Cypress Angular Handler moved as a result of [this commit](/~https://github.com/angular/angular-cli/commit/466d86dc8d3398695055f9eced7402804848a381) from Angular. Addressed in [#27030](/~https://github.com/cypress-io/cypress/pull/27030).
- Fixed an issue where certain commands would fail with the error `must only be invoked from the spec file or support file` when invoked with a large argument. Fixes [#27099](/~https://github.com/cypress-io/cypress/issues/27099).

Expand Down
13 changes: 11 additions & 2 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1899,18 +1899,27 @@ declare namespace Cypress {
* @see https://on.cypress.io/screenshot
* @example
* cy.screenshot()
* cy.get(".post").screenshot()
*/
screenshot(options?: Partial<Loggable & Timeoutable & ScreenshotOptions>): Chainable<null>
/**
* 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.get(".post").screenshot("post-element")
* cy.screenshot("post-element")
*/
screenshot(fileName: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions>): Chainable<null>

/**
* Take a screenshot of the application under test and the Cypress Command Log and save under given filename.
* When this method is chained it will also pass the context along to the screenshot.
*
* @see https://on.cypress.io/screenshot
* @example
* cy.get(".post").screenshot("post-element")
*/
screenshot(context: string, fileName?: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions>): Chainable<null>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming the context parameter is meant to represent the subject from the previously-chained command? I think that should look more like this (note the Chainable<Subject> instead of Chainable<null>) based on examples elsewhere in this file

screenshot(fileName?: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions>): Chainable<Subject>,

Copy link
Contributor Author

@0neMiss 0neMiss Jun 28, 2023

Choose a reason for hiding this comment

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

Hey sorry! Yea I'm having a hard time getting the yarn install to work. Something about python versions and some microsoft tools. That's why I marked it as a draft because I haven't actually been able to run and build this locally yet.

I also saw that this check was failing and I wasn't sure what steps to take to resolve that. Any help on either of those things would be appreciated!

I'll update to fix the Chainable<Subject> and the changelog. I actually don't know why I called that variable context haha.

I'll add those test cases as well, granted that I figure out this issue with running locally. If you have some suggestions for me to try i'd be happy to. Otherwise this might have to wait till later this week when I'm a little more available.

Thanks for taking a look @mike-plummer

Copy link
Contributor Author

@0neMiss 0neMiss Jul 2, 2023

Choose a reason for hiding this comment

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

@mike-plummer Ready for another pass I think!


/**
* Scroll an element into view.
*
Expand Down