Karate IntelliSense for VS Code
A high-performance, intelligent, and context-aware VS Code extension designed specifically for Karate DSL (.feature) test automation files. It brings robust IDE features—such as smart auto-completion, rich hover documentation, parameter signature help, syntax highlighting, and Go to Definition tag navigation—directly to your Karate workflows.
✨ Key Features & Capabilities
1. 🚀 Intelligent Auto-Completion (Ctrl + Space)
The extension analyzes your cursor context in real-time to provide precise, relevant suggestions:
- Karate Steps & Browser Automation: Autocomplete for standard Karate steps and browser actions including
waitFor, select, input, inputFile, script, mouse, mouseMove, key, keys, click, text, value, attribute, delay, and screenshot.
- Chained Step Support: Smart completion inside compound steps like
* call read(...).
match expressions: After * match or * match each , suggests browser helpers used in assertions (e.g. * match text('#title') == 'Home', * match attribute('#link', 'href') contains 'https').
- Assignment RHS: Completions on the right-hand side of
* def var = ... (e.g. * def label = tex → text).
karate.* JavaScript APIs: Full suggestions for core Karate runtime functions such as karate.get(), karate.set(), karate.call(), and karate.read().
driver.* Methods: Comprehensive driver automation methods including driver.intercept(), driver.back(), driver.title(), driver.screenshot(), and driver.quit().
Key.* Keyboard Constants: Easy access to keyboard event constants like Key.ENTER, Key.TAB, Key.SPACE, and Key.ESCAPE.
- UI Element Method Chaining: Intelligent completion for fluent UI element interactions across any variable name (e.g., typing
element. suggests locate, and chaining .locate(locator). suggests methods like getText, click, input, clear, focus, attribute, enabled, present, visible, etc.).
- Step vs. chained
attribute: The step attribute(locator, name) (including in match) is separate from the chained UI method .attribute(name)—hover and signature help pick the correct signature from context.
2. 🔗 Go to Definition & Tag Navigation (Ctrl + Click)
- File Path Resolution: Navigate effortlessly from file paths referenced in Karate expressions (such as
karate.call('../features/subFeature.feature@tagName', ...) or call read('...')) directly to the target file.
- Exact Tag & Scenario Jump: When a tag suffix is appended (e.g.,
@tagName or @scenarioName), the extension parses the target .feature file, finds the exact line where the tag is declared, and jumps your cursor directly to that line.
- Locator navigation: Ctrl+click the locator variable (e.g.
pageLocators in pageLocators.submitButton) to open its read() file at the top; Ctrl+click the property name to jump to that key. Works with * def pageLocators = call read('../locators/page.js') in the same feature (including Background:).
- Local
* def navigation: Ctrl+click a variable defined earlier in the same feature (e.g. resultId in a print step) to jump to its * def resultId = ... line.
3. 📖 Rich Hover Documentation
- Hover over any Karate step, API function, driver command, or UI element method to view structured Markdown documentation.
- Includes exact syntax signatures, descriptions, parameter tables, and copy-pasteable usage examples.
4. 💡 Signature Help & Parameter Hints
- As you type function arguments (e.g.,
driver.intercept(...), input(locator, value, key?), * match attribute(locator, name), or myElement.attribute(name)), active parameter highlighting guides you through each required and optional argument.
5. 🎨 Syntax Highlighting
Karate steps such as waitFor and waitForText keep their normal step color. The extension adds color for the values you write around those steps:
- Locator variables and fields: In
click(pageLocators.submitButton), pageLocators and submitButton use different colors. The same applies to variables loaded with * def pageLocators = read('locators.js') or call read(...).
- JavaScript members:
.length, .trim(), .toUpperCase(), and other calls such as .split() use a separate color from locator fields, as in order.items.length.
- Variables: A standalone variable such as
resultId in * print 'Order id:', resultId or * select(pageLocators.roleDropdown, resultId) is colored as a variable.
- Embedded object keys and values: Inside a multiline
* def body, keys and quoted values are colored separately:
* def order =
"""
{
name: 'notebook',
sku: 'NB-100',
quantity: 2
}
"""
🛠️ Development & Getting Started
Prerequisites
Installation & Compilation
# Clone repository
git clone https://github.com/bhanuagarwal73/karate-intellisense.git
cd karate-intellisense
# Install dependencies
npm install
# Compile TypeScript
npm run compile
Running Unit Tests
The extension includes a standalone unit test suite that validates completion, hover, signature, definition, and highlighting behavior without needing the VS Code GUI:
npm run compile && node out/test/run.js
Testing inside VS Code (Extension Development Host)
- Open this repository folder in VS Code.
- Press F5 to compile and launch a new Extension Development Host window.
- Open any
.feature file and test auto-completion (Ctrl + Space), hover documentation, signature help, syntax highlighting, and Go to Definition (Ctrl + Click).
📄 License
Distributed under the MIT License. See LICENSE for more information.
| |