mbolotov / intellij-cypress

IntelliJ-Cypress plugin: https://plugins.jetbrains.com/plugin/13819-intellij-cypress Pro version: https://plugins.jetbrains.com/plugin/13987-cypress-support-pro
MIT License
35 stars 5 forks source link

cypress-support-pro plugin causes custom command warnings #20

Closed ponienchen closed 4 years ago

ponienchen commented 4 years ago

I am using intelliJ Ultimate IDE.

I have custom commands in support/commands.js and their type definitions defined in support/index.d.ts

When I enable the plugin, my test files start to complain about my custom commands: "Method Expression is not of Function type". And if I use command+B to view custom command usages, it will be excluded from the search results, making it quite inconvenient for me.

As soon as I disable the plugin, the warning is gone and everything goes back to normal. I think it is caused by the plugin's auto completion support: "Auto completion and navigation for aliases references, fixtures and custom commands (PRO version only)"

Could you please get it fixed ?

mbolotov commented 4 years ago

Hi @ponienchen! Please specify the version of IDE and the sample of your command. I just tried 2020.2 and was unable to reproduce.

ponienchen commented 4 years ago

Thanks for your reply.

My ultimate version is IntelliJ IDEA 2020.2.2 (Ultimate Edition) Build #IU-202.7319.50

Sample command:

Cypress.Commands.add("login", (email, password) => {
    console.log(password);
});

Type Definition in support/index.d.ts: Screen Shot 2020-10-01 at 9 41 24 AM

using the command:

cy.login('abcdefg');

The plugin's autocomplete works. Screen Shot 2020-10-01 at 9 35 46 AM

But got the warning message:

Screen Shot 2020-10-01 at 9 37 07 AM

========================================

What it looks like before enabling the plugin: Screen Shot 2020-10-01 at 9 43 25 AM

mbolotov commented 4 years ago

Oh, it seems I'm starting to understand the problem. You have your code in a JS file, right? Some background at the plugin side: plugin make special efforts on supporting custom commands for JS tests only since in TS case, it's easy to get the definitions down and have all the code completion and navigation features done by the IDE itself. So I've actually never tried tests in JS with TS definitions. I'll look into this case. BTW, why don't you use TS everywhere?

ponienchen commented 4 years ago

I didn't have particular needs to use TS everywhere else, except for type definition for making auto-completion work for custom commands.

I was following this example to set up the auto-completion.

https://docs.cypress.io/guides/tooling/intelligent-code-completion.html#Set-up-in-your-Dev-Environment

https://github.com/cypress-io/cypress-example-todomvc#custom-commands
mbolotov commented 4 years ago

Okay, I'll probably disable direct custom command resolving in plugin in the favor of TS definitions. I'll also probably add some support to make it easier to work with the definitions file.

ponienchen commented 4 years ago

Thank you so much for your help!

mbolotov commented 4 years ago

Hi @ponienchen! In version 1.6.1, I've added the ability to disable custom command support (as well as alias and fixture ones) via the Registry. You can call it by Tools -> Internal Actions -> Registry menu item: image

So closing this issue now.

ponienchen commented 4 years ago

Than you for the update. It is working for me.