将功能映射到 "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

所以我刚刚下载了 "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
}

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