在“VSCode Cucumber (Gherkin) Full Language Support + Formatting + Autocomplete”插件的设置文件中将要素映射到步骤定义

Mapping features to step definitions in the settings file for the "VSCode Cucumber (Gherkin) Full Language Support + Formatting + Autocomplete" plugin

提问人:Luke 提问时间:1/18/2020 最后编辑:Luke 更新时间:1/27/2020 访问量:2168

问:

所以我刚刚下载了“VSCode Cucumber (Gherkin) Full Language Support + Formatting + Autocomplete” 插件来帮助在我的 vscode 编辑器中进行黄瓜格式化。从他们的文档来看,“VSCode Cucumber (Gherkin)...”插件支持一项功能,该功能允许您通过将鼠标悬停在 .feature 文件中的相应文本上来查看功能文件、步骤定义和页面对象之间的关系。

然而,“VSCode Cucumber (Gherkin)...”插件关于文件之间路径映射的文档是轻量级的。有谁知道在给定以下目录结构的情况下,您将如何在功能文件、步骤定义和页面对象之间创建所需的语法链接?

src
├── features
│   ├── accessibility
│   │   └── FeatureFile.feature
│   ├── Directory
│   │   ├── featureFile.feature
│   │   ├── SomeDirectory
│   │   │   ├── FeatureFile.feature
│   ├── step_definitions
│   │   ├── SomeDirectory
│   │   │   ├── someFile.js
│   │   │   ├── given.js
│   │   │   └── then.js
│   │   ├── given.js
│   │   ├── someFeature.js
│   │   ├── then.js
│   │   └── when.js
├── pageobjects
│   ├── SomeDirectory
│   │   ├── SomeFeature

作为参考,这是他们的文档示例,说明 vscode 配置文件应如何启用这些功能

{
"cucumberautocomplete.steps": [
    "test/features/step_definitions/*.js",
    "node_modules/qa-lib/src/step_definitions/*.js"
],
"cucumberautocomplete.syncfeatures": "test/features/*feature",
"cucumberautocomplete.strictGherkinCompletion": true,
"cucumberautocomplete.strictGherkinValidation": true,
"cucumberautocomplete.smartSnippets": true,
"cucumberautocomplete.stepsInvariants": true,
"cucumberautocomplete.customParameters": [
    {
        "parameter":"{ab}",
        "value":"(a|b)"
    },
    {
        "parameter":/\{a.*\}/,
        "value":"a"
    },
],
"cucumberautocomplete.pages": {
    "users": "test/features/page_objects/users.storage.js",
    "pathes": "test/features/page_objects/pathes.storage.js",
    "main": "test/features/support/page_objects/main.page.js"
},
"cucumberautocomplete.skipDocStringsFormat": true,
"cucumberautocomplete.formatConfOverride": {
    "And": 3,
    "But": "relative",
},
"cucumberautocomplete.onTypeFormat": true,
"editor.quickSuggestions": {
    "comments": false,
    "strings": true,
    "other": true
}
javascript selenium-webdriver cucumber bdd visual-studio-code

评论

1赞 supputuri 1/22/2020
cucumberautocomplete.steps应具有有效路径数组。在您的情况下,您可以指定 .如果你想阅读src中任何文件夹中的步骤,你可以简单地提到.试一试,让我知道它是怎么回事。["path_to_src/features/step_definitions/*.js"]["path_to_src/**/*.js"]

答:

1赞 supputuri 1/27/2020 #1

cucumberautocomplete.steps应具有有效路径数组。在您的情况下,您可以指定 .如果你想阅读src中任何文件夹中的步骤,你可以简单地提到["path_to_src/features/step_definitions/*.js"]["path_to_src/**/*.js"]