-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Actions before raising this issue
- I searched the existing issues and did not find anything similar.
- I read/searched the docs
Is your feature request related to a problem? Please describe.
At the moment, our Cypress custom commands don't get autocomplete and typehints in VSCode.
The commands are not recognized by the ide, to pick a command developer has to manually search by exact command names in the project.
Describe the solution you'd like
Generate a index.d.ts file and autoupdate it on save with the help of CypressHelper VSCode extension (which is recommended by Cypress docs).
This will only require installing CypressHelper to VSCode and updating .vscode/settings.json with
{
"cypressHelper.typeDefinitionOnSave": true,
"cypressHelper.customCommandsFolder": "tests/cypress/support",
"cypressHelper.typeDefinitionFile": "tests/cypress/support/index.d.ts",
}and adding /// <reference types="../../support/index.d.ts" /> to a file to enable hints
This simple update will not require us to rewrite all tests to typescript, but this will make VSCode recognise latest list of commands and offer them to the developer in dropdown menus (todo: drop a gif with demo).
Describe alternatives you've considered
No response
Additional context
A separate task is providing definitions to commands in custom plugins inside cypress/plugins. Cypress Helper can autogenerate type definitions but it requires one custom commands folder. So extra effort is needed to additionally maintain type definitions for plugins. I've already filed an issue to Cypress Helper support team, but in the meantime we have some options to get type definitions:
- Manually maintain a
cypress/plugins/index.d.tswith typedcy.task's as suggested here - Write a script to autogenerate those typedefs, could be done using existing logic from Cypress Helper iself. The script can be run e.g. in a
.huskypre-commit