Adding custom commands throws IDE errors
See original GitHub issueCurrent behavior:
When adding a new custom command, like
Cypress.Commands.add('login', (user) => {
JetBrains (GoLand in my case) doesn’t recognise the command and throws an error on it.
This shows errors all they way up the file tree in my IDE
Desired behavior:
I would like to be able to register the command to the IDE to prevent theseissues
Versions
Goland 2020.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:18 (2 by maintainers)
Top Results From Across the Web
Handling Exceptions in Your Custom Command
If you have a custom command and an exception is thrown within your code, good programming practice is to handle that exception and...
Read more >Cypress custom command is not recognized when invoked
login(testuser, testpwd) , but I'm getting the following error message: TypeError: cy.login is not a function . The docs say that /cypress/ ...
Read more >TypeScript - Cypress Documentation
When adding custom commands to the cy object, you can manually add their types to avoid TypeScript errors. For example if you add...
Read more >Troubleshoot development errors with Office Add-ins
Learn how to troubleshoot development errors in Office Add-ins. ... The add-in has a custom Add-in Command but you are trying to run...
Read more >A Definitive Guide to Handling Errors in JavaScript - Kinsta
Types of Errors in JavaScript; Creating Custom Error Types ... JavaScript allows you to throw anything literally with the throw command.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After relooking at this, it seems that adding the reference to the
index.d.ts
file at the top of thesupport/index.ts
file will cause the types to work correctly.@rkorebrits Can you confirm that this fixes your types?
There’s some discussion here on this situation.
support/index.ts
I’ve confirmed that this example from our docs to define Type definitions for custom commands does not work when the
support/index
file where the custom command is defined is a TypeScript file. If you renamed thesupport/index.ts
file tosupport/index.js
(being a JavaScript file) - the type definition works for the spec.Repro
cypress/support/index.d.ts
cypress/support/index.ts
- works ifcypress/support/index.js
cypress/integration/spec.ts
Not sure if this is some bug or issue with our documentation that needs updating.