How do I get WebdriverIO autocomplete on VS Code

后端 未结 3 892
余生分开走
余生分开走 2021-01-21 09:43

Is there a way I can get autocomplete on VS Code for webdriverio?

Other code editors like Intellij provide something like Settings -> Preferences -> Languages & Fram

相关标签:
3条回答
  • 2021-01-21 10:34

    my understanding is, vscode is built with typescript and by default it does not support autoComplete(Intellisense) on a package that is built with javascript. So all the js package creators would provide an @types file. These @types file help vscode to find all the function definitions, object properties. etc., etc., of your JS package and show as suggestions. Which in case here is webdriverio package.

    So adding a @types dependency that is related to your JS package will mostly fix the issue. i.e.,

    npm install @types/webdriverio --save-dev
    

    After adding the package, i started getting the browser object suggestions.

    All the above works fine for v4 version of WDIO.

    If you are using v5 version: Then as per their official documentation we need to create a jsconfig.json file on the root directory.

    0 讨论(0)
  • 2021-01-21 10:38

    Above answer worked well :

    you need to install below dependency :

    if you are using webdriverio v4 (for cucumber BDD ) use below 
    npm install @types/webdriverio@4 --save-dev
    
    or use :
    npm install @types/webdriverio --save-dev

    VSCode Intellisense

    0 讨论(0)
  • 2021-01-21 10:42

    Using @types/webdriverio is not suggested by webdriverio and it is now deprecated: npm WARN deprecated @types/webdriverio@5.0.0: This is a stub types definition. webdriverio provides its own type definitions, so you do not need this installed.

    I would suggest to follow the official documentation by WebDriverIO here:

    0 讨论(0)
提交回复
热议问题