Contributing to Gherkin PowerTools
Thank you for your interest in contributing to Gherkin PowerTools! This document explains our architecture, how to set up the project locally, and how to submit your contributions.
๐๏ธ Architecture Overview
The extension is written in TypeScript and uses the native VS Code Extension API. It is built with performance and maintainability in mind.
Here is a breakdown of the core modules located in the src/ directory:
extension.ts: The entry point. Registers all commands, providers (Formatter, Definition, Outline), and initializes the diagnostics.formatter.ts: The core AST-based formatter. It handles indentation, table alignment, auto-casing, and tag wrapping based on@cucumber/gherkinparses.highlighter.ts: Implements custom semantic syntax highlighting via VS Code'screateTextEditorDecorationTypeAPI.linter.ts: Uses the official@cucumber/gherkinAST parser to perform real-time syntax checking. Generatesvscode.Diagnosticwarnings to underline mistakes in the editor.definition.ts: The Go-To-Definition provider. Reads.featuresteps and recursively searches thesteps/folder for Python (.py) files with matching@given,@when,@thendecorators.outline.ts: Constructs the hierarchical tree ofFeature > Rule > Scenariofor the VS Code Outline panel.statistics.ts: Generates the interactive HTML Webview dashboard by parsing workspace files to count BDD metrics.
๐ ๏ธ Local Setup
- Prerequisites: Ensure you have Node.js (v16+) and npm installed.
- Clone the repository:
- Install dependencies:
- Compile the TypeScript code:
- Run the Extension:
- Press
F5in VS Code to open a new "Extension Development Host" window. - Any changes you make to the code can be tested by reloading the Development Host (
Cmd + R/Ctrl + R).
๐งช Testing
We use the official @vscode/test-electron framework coupled with Mocha to run tests. Our tests are split into two categories to maximize efficiency and reliability:
Unit Tests
To run ultra-fast unit tests that validate the AST processor and algorithms:
To run the unit tests and generate an LCOV coverage report:
End-to-End (E2E) UI Tests
To run native UI integration tests that launch a real VS Code instance and test features like formatting, outline generation, and linting directly via the VS Code Extension APIs:
[!IMPORTANT] Always ensure that all tests pass before submitting a Pull Request. If you are adding a new feature, please add a corresponding test case in the
test/directory.
๐ค CI/CD Pipeline
Our CI/CD pipeline leverages reusable GitHub Actions from the qa-hub-actions repository. This ensures consistency across quality checks. Specifically, coverage reporting and other QA gates are handled externally by these actions.
๐ฆ Packaging
To create a local .vsix file for distribution or local testing:
This will generate a vscode-gherkin-powertools-x.x.x.vsix file in the root directory.
๐ค Submitting a Pull Request
[!NOTE] If you are planning a large feature or significant architectural change, please open an Issue or Discussion first to align with the project maintainers before writing code.
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature/my-new-feature - Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/my-new-feature - Open a Pull Request against the
mainbranch.
We look forward to reviewing your code!