generate_feature_file
Create WDIO feature files using Gherkin syntax (Given, When, Then) for test automation. Define scenario titles, tags, and output paths to generate structured test files for WebDriverIO.
Instructions
Generate WDIO feature file with Gherkin syntax (Given, When, Then)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gherkin_syntax | Yes | Gherkin syntax content for the feature | |
| output_path | Yes | Path where the feature file should be saved | |
| scenario_title | Yes | Title of the test scenario | |
| tags | No | Test ID tags for the scenario |
Implementation Reference
- index.js:979-998 (handler)Main handler function for 'generate_feature_file' tool. Extracts parameters, generates content using helper method, writes to output_path, and returns success response.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:173-202 (schema)Tool configuration including schema definition for input validation. Used for both listing tools and validating args before execution.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:348-350 (registration)Dispatch registration in CallToolRequestSchema handler: routes tool calls to the generateFeatureFile handler method.case 'generate_feature_file': return await this.generateFeatureFile(args); case 'generate_steps_file':
- index.js:1098-1105 (helper)Helper method that constructs the Gherkin feature file content from title, syntax, and tags. Called by the handler.buildFeatureFileContent(scenario_title, gherkin_syntax, tags) { const tagString = tags.map(tag => `@${tag}`).join(' '); return `${tagString ? tagString + '\n' : ''}Feature: ${scenario_title} ${gherkin_syntax} `; }
- index.js:330-334 (registration)Registers the tool for discovery: ListToolsRequestSchema returns the tool list including generate_feature_file config.this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolConfigs, }; });