generate_feature_file
Create WDIO feature files with Gherkin syntax for test automation scenarios, specifying scenario titles, steps, tags, and output paths.
Instructions
Generate WDIO feature file with Gherkin syntax (Given, When, Then)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scenario_title | Yes | Title of the test scenario | |
| gherkin_syntax | Yes | Gherkin syntax content for the feature | |
| tags | No | Test ID tags for the scenario | |
| output_path | Yes | Path where the feature file should be saved |
Implementation Reference
- index.js:979-998 (handler)The primary handler function for the 'generate_feature_file' tool. It destructures the input arguments, generates the feature file content using an internal helper, ensures the output directory exists, writes the file, and returns a success response with the generated content.async generateFeatureFile(args) { const { scenario_title, gherkin_syntax, tags = [], output_path } = args; try { const featureContent = this.buildFeatureFileContent(scenario_title, gherkin_syntax, tags); await fs.ensureDir(path.dirname(output_path)); await fs.writeFile(output_path, featureContent); return { content: [ { type: 'text', text: `Feature file generated successfully at: ${output_path}\n\nContent:\n${featureContent}`, }, ], }; } catch (error) { throw new Error(`Failed to generate feature file: ${error.message}`); }
- index.js:175-200 (schema)The JSON Schema defining the input parameters and validation rules for the generate_feature_file tool, including required fields and constraints.inputSchema: { type: 'object', properties: { scenario_title: { type: 'string', description: 'Title of the test scenario', minLength: 1, }, gherkin_syntax: { type: 'string', description: 'Gherkin syntax content for the feature', minLength: 1, }, tags: { type: 'array', items: { type: 'string' }, description: 'Test ID tags for the scenario', }, output_path: { type: 'string', description: 'Path where the feature file should be saved', minLength: 1, }, }, required: ['scenario_title', 'gherkin_syntax', 'output_path'], additionalProperties: false,
- index.js:173-202 (registration)The tool configuration object in the toolConfigs array, which registers the generate_feature_file tool with its name, description, and schema for the MCP server's listTools response.name: 'generate_feature_file', description: 'Generate WDIO feature file with Gherkin syntax (Given, When, Then)', inputSchema: { type: 'object', properties: { scenario_title: { type: 'string', description: 'Title of the test scenario', minLength: 1, }, gherkin_syntax: { type: 'string', description: 'Gherkin syntax content for the feature', minLength: 1, }, tags: { type: 'array', items: { type: 'string' }, description: 'Test ID tags for the scenario', }, output_path: { type: 'string', description: 'Path where the feature file should be saved', minLength: 1, }, }, required: ['scenario_title', 'gherkin_syntax', 'output_path'], additionalProperties: false, }, },
- index.js:1098-1105 (helper)Helper method used by the handler to construct the Gherkin feature file content from scenario title, syntax, and tags.buildFeatureFileContent(scenario_title, gherkin_syntax, tags) { const tagString = tags.map(tag => `@${tag}`).join(' '); return `${tagString ? tagString + '\n' : ''}Feature: ${scenario_title} ${gherkin_syntax} `; }