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

Cypress Document function typing is incorrect #17695

Closed
JordanMcDonough opened this issue Aug 11, 2021 · 4 comments · Fixed by #17706
Closed

Cypress Document function typing is incorrect #17695

JordanMcDonough opened this issue Aug 11, 2021 · 4 comments · Fixed by #17706
Labels
good first issue Good for newcomers type: typings Issue related to Cypress types (for TypeScript)

Comments

@JordanMcDonough
Copy link
Contributor

JordanMcDonough commented Aug 11, 2021

Current behavior

The cy.document function has the wrong typings for typescript.
In the docs it specifies timeout as a valid property, however it only has the log option specified.
https://docs.cypress.io/api/commands/document#Usage

image

Desired behavior

The type file should specify it to be timeoutable:

    /**
     * Get the window.document of the page that is currently active.
     *
     * @see https://on.cypress.io/document
     * @example
     *    cy.document()
     *      .its('contentType')
     *      .should('eq', 'text/html')
     */
    document(options?: Partial<Loggable & Timeoutable): Chainable<Document>

Test code to reproduce

describe('a test', () => {
    it('should have the right typing', () => {
        // The below should not throw a type error
        cy.document({ timeout: 5000 }).should('exist');
    });
});

Cypress Version

8.0.0

Other

Temporary workaround:

Create the following file: ./src/@types/cypress.d.ts
With the content:

declare namespace Cypress {
    interface Chainable {
        document(options?: Partial<Loggable & Timeoutable>): Chainable<Document>
    }
}
@jennifer-shehane jennifer-shehane added type: typings Issue related to Cypress types (for TypeScript) stage: ready for work The issue is reproducible and in scope good first issue Good for newcomers labels Aug 11, 2021
@jennifer-shehane
Copy link
Member

Thanks for pointing this out. It does indeed accept both of those options. We would be open to reviewing a PR with this update.

@JordanMcDonough
Copy link
Contributor Author

Thanks for pointing this out. It does indeed accept both of those options. We would be open to reviewing a PR with this update.

Will do

@jennifer-shehane
Copy link
Member

The code for this is done, but this has yet to be released. We'll update this issue and reference the changelog when it's released.

@jennifer-shehane jennifer-shehane added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Aug 26, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 27, 2021

Released in 8.3.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v8.3.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers type: typings Issue related to Cypress types (for TypeScript)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants