VS Code 中的 Webdriver io 自动完成
Webdriver io autocomplete in VS Code
我使用 Webdriver IO 作为 e2e 测试框架。但是这个自动完成问题真的让我慢了下来。 VS Code 不会自动完成全局变量 browser
及其方法。
.eslintrc
{
"extends": ["eslint:recommended", "standard"],
"parser": "babel-eslint",
"plugins": [
"mocha",
"webdriverio"
],
"env": {
"webdriverio/wdio": true,
"mocha": true
},
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
"indent": ["error", 4]
}
}
.babelrc
{
"presets": ["es2015"],
"plugins": [
["transform-runtime", {
"polyfill": false
}]
]
}
我认为你可以使用 TypeScript 打字。
向 package.json 添加 2 个依赖项:
"@types/node": "^8.5.2",
"@types/webdriverio": "^4.8.7",
安装它们,重新加载项目。如果自动完成还不起作用,请创建
tsconfig.json 在项目的根目录中:
{
"compilerOptions": {
"allowJs": true,
"outDir": "./.built/"
}
}
您不需要使用 typescript 编译器,它只会提供自动完成功能。像往常一样继续编写您的 js 代码。
但是如果你想使用打字稿,这里有一个新手小指南:
http://webdriver.io/guide/getstarted/configuration.html#Setup-TypeScript
我使用 Webdriver IO 作为 e2e 测试框架。但是这个自动完成问题真的让我慢了下来。 VS Code 不会自动完成全局变量 browser
及其方法。
.eslintrc
{
"extends": ["eslint:recommended", "standard"],
"parser": "babel-eslint",
"plugins": [
"mocha",
"webdriverio"
],
"env": {
"webdriverio/wdio": true,
"mocha": true
},
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
"indent": ["error", 4]
}
}
.babelrc
{
"presets": ["es2015"],
"plugins": [
["transform-runtime", {
"polyfill": false
}]
]
}
我认为你可以使用 TypeScript 打字。
向 package.json 添加 2 个依赖项:
"@types/node": "^8.5.2",
"@types/webdriverio": "^4.8.7",
安装它们,重新加载项目。如果自动完成还不起作用,请创建 tsconfig.json 在项目的根目录中:
{
"compilerOptions": {
"allowJs": true,
"outDir": "./.built/"
}
}
您不需要使用 typescript 编译器,它只会提供自动完成功能。像往常一样继续编写您的 js 代码。
但是如果你想使用打字稿,这里有一个新手小指南: http://webdriver.io/guide/getstarted/configuration.html#Setup-TypeScript