visual-studio-codeautocompletewdio-v5

WebdriverIO autocomplete in VSCODE


I am wonder, if it is way how to enable autocompletion for WDIO global variables ( $, $$, browser ) in VSCode. I know, that wdio has support for Webstorm, but it doesn't work for VSCode.

Any idea, how to use autocompletion in VSCode? Without it is pretty hard to create some tests.


Solution

  • I struggled with this as well. Firstly, ensure you've followed the "Autocompletion" Setup described on the website; for example, they require something like the following exist in a file called jsconfig.json at the root of your project:

    {
      "include": [
        "**/*.js",
        "**/*.json",
        "node_modules/@wdio/sync",
        "node_modules/@wdio/mocha-framework"
      ]
    }
    

    You may already have a jsconfig.json; if so, ensure that the node_modules directories are not in a section called "exclude": { ... }. When setting up other things like Babel (for mocha) this may get installed as a default configuration entry. When node_modules is in both include and exclude, exclude takes precedence.

    I had zero success importing npm @types pacakges, adding typeAcquisition: {} to jsconfig.json, or adding interface browser; into the file global.d.ts as other people have suggested in various forums.