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

cy.contains(content, options) syntax works, but missing in typescript declaration and not documented #4727

Closed
jodelasur opened this issue Jul 16, 2019 · 5 comments · Fixed by #4756
Labels

Comments

@jodelasur
Copy link

Current behavior:

I tried cy.contains('content', {timeout: 6000}) and it works, but my IDE is complaining that "Argument types do not match parameters". I checked types/index.d.ts and didn't find a matching declaration.

image

I also checked the documentation and didn't find it referenced.

image

Desired behavior:

Just want to make this function signature official, as I happen to use it many times (and others might as well).

Versions

Cypress 3.3.2, Windows 10, Chrome 75

@bahmutov
Copy link
Contributor

The typescript definition for cy.contains are included, see https://github.com/cypress-io/cypress/blob/develop/cli/types/index.d.ts#L577

I suggest restarting TS server in your IDE, sometimes it gets frozen?

@jodelasur
Copy link
Author

Yes, I reviewed the definitions file, but the exact definition I'm looking for (with two arguments: a content string, and an optional options object) isn't there.

I think the params list of lines 577 and 586 should be extended as
(content: string | number | RegExp, options?: Partial<Loggable & Timeoutable>).

Then the documentation should add cy.contains(content, options) as another syntax.

I could make a pull request, but can only do so later in the week.

@jennifer-shehane
Copy link
Member

Yes, this is a valid use of .contains() as noted in the code here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/querying.coffee#L288 - the TypeScript defs should be updated.

I updated the docs here: cypress-io/cypress-documentation@7c1ce33

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jul 17, 2019
@jennifer-shehane jennifer-shehane added the good first issue Good for newcomers label Jul 17, 2019
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Jul 18, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 19, 2019

The code for this is done in cypress-io/cypress#4756, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Jul 19, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 29, 2019

Released in 3.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants