-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Intelligent Code Completion to show Custom Commands #2293
Comments
Our intelligent code completion works by using our typescript definitions. I'm not sure how familiar you are with TypeScript, but you can extend those definitions within your custom commands to define the expectations you need like is done in @d3lm project: https://github.com/d3lm/ngx-drag-to-select/blob/master/cypress/support/commands.ts#L105-L114 |
Hey, thanks for the response.
I am not really familiar with ts...yet.
So it means I would need to convert all my .js custom commands to .ts then include webpack package (or similar tool) into the project to convert it back to .js right?
…________________________________
From: Jennifer Shehane <notifications@github.com>
Sent: Wednesday, August 8, 2018 20:00
To: cypress-io/cypress
Cc: kapalkat; Author
Subject: Re: [cypress-io/cypress] Intelligent Code Completion to show Custom Commands (#2293)
Our intelligent code completion works by using our typescript definitions. I'm not sure how familiar you are with TypeScript, but you can extend those definitions within your custom commands to define the expectations you need like is done in @d3lm<https://github.com/d3lm> project: https://github.com/d3lm/ngx-drag-to-select/blob/master/cypress/support/commands.ts#L105-L114
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#2293 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AZfK0oMJGSyHbny6g7UTxQLDkq8sRpWOks5uOycwgaJpZM4VxyoT>.
|
Yep, you would then write your tests with TS instead of JavaScript. An easy solution is to use https://github.com/bahmutov/add-typescript-to-cypress. All you have to do is to install this via npm or yarn and create a Also make sure to check the documentation https://docs.cypress.io/guides/tooling/typescript-support.html |
OK, thanks for the information.
That's too much hassle for me as I already have over 200 test specs in javascript.
It would be faster for me to change it to standalone pure javascript functions and put it to some other utility.js file.
Thanks anyway!
BTW: You could provide this information in your docs in the future to avoid this kind of surprises:)
…________________________________
From: Dominic E. <notifications@github.com>
Sent: Friday, August 10, 2018 11:48
To: cypress-io/cypress
Cc: kapalkat; Author
Subject: Re: [cypress-io/cypress] Intelligent Code Completion to show Custom Commands (#2293)
Yep, you would then write your tests with TS instead of JavaScript. An easy solution is to use https://github.com/bahmutov/add-typescript-to-cypress. All you have to do is to install this via npm or yarn and create a tsconfig.json inside your cypress folder. For reference check out this config https://github.com/d3lm/ngx-drag-to-select/blob/master/cypress/tsconfig.json. You also need to install typescript via npm or yarn.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#2293 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AZfK0oOuQwHXl5Jr_aOmG24Jnc5mbqtiks5uPVb0gaJpZM4VxyoT>.
|
I created a new issue in our docs to document adding custom command support to intelligent code completion here: cypress-io/cypress-documentation#1354. Our documentation is open source and contributions are welcome. 😄 |
There is no need to transform your specs to TypeScript, nor installing any 3rd party library. All you need to do is:
/// <reference types="Cypress" />
/// <reference types="../support" />
/// <reference types="Cypress" />
declare namespace Cypress {
interface Chainable {
myCustomCommandA(selector: string, option: string): Cypress.Chainable<JQuery>;
myCustomCommandB(param: string, value: any): Cypress.Chainable<JQuery>;
}
} This process is documented in this page of the documentation. |
The typescript definition file seems completely unuseable and unscalable. This file will get massive and it's just a forward declarations/headers file. The last time I had to forward declare my function definitions was in C++. |
I think this ticket should be reopened because the current solution is infeasible. |
@lsdkjflasjflkdasj Please follow this issue for fully integrated TypeScript support. #1859 This is the solution we have for today. |
Current behavior:
Intelligent Code Completion feature doesn't show results for Custom Commands.
When you create a lot of them it is really hard to find the name in the file. When you work in cooperation with many team members and few of them are adding custom commands you don't even know what has been added.
The one more really annoying thing is that you can't jump to custom command declaration from your test file like for any other imported function or class.
This one together with the above problem makes Custom Commands almost impossible to maintain!
Desired behavior:
Intelligent Code Completion should work with custom commands.
Versions
Cypress 3.0.3
The text was updated successfully, but these errors were encountered: