Skip to main content

GET STARTED

Windows Quick Start (VS Code)

Take the karate-demo project from a ZIP to a green run, a bug found in the debugger and the HTML report, on a Windows machine where VS Code is the only thing installed. No Java, no Maven, no admin rights.

Watch on YouTube: Karate for VS Code on Windows: write it, run it, debug it (2:16)

You need: Windows x64, VS Code, an internet connection, and a karatelabs.io account with IDE Plus (to run tests in the editor) or IDE Pro (to debug as well).

The Demo Project​

karate-demo is a small Karate project with no pom.xml, no build.gradle and no Java code:

FileWhat it shows
features/cart/cart.featureA cart invoice computed in JavaScript, both inline and in invoice.js, plus a Scenario Outline with an Examples table. No server, no network.
features/cart/invoice.jsThe invoice function the feature reads; the place to set a breakpoint.
features/api/todos.featureAn API test against its own mock (todos-mock.feature), which it starts itself.
karate-pom.jsonTells the Karate CLI and the extension which folder holds the tests.
.vscode/extensions.jsonRecommends the Karate extension.

1. Download and Extract​

  1. Download the ZIP: karate-demo-main.zip (or Code → Download ZIP on GitHub).
  2. In File Explorer, right-click karate-demo-main.zip → Extract All.
Open the inner folder

Extract All nests the project one level down: karate-demo-main\karate-demo-main. The folder to open is the one that holds karate-pom.json. Opening the outer folder leaves the Testing view empty.

2. Open the Folder​

In VS Code: File → Open Folder…, pick the folder that holds karate-pom.json, and click Yes, I trust the authors. The Karate extension stays disabled in Restricted Mode, so the folder must be trusted.

3. Install the Extension​

  1. Open the Extensions view (Ctrl+Shift+X) and search for karate.
  2. Several extensions have similar names. Install Karate whose publisher is Karate Labs (id karatelabs.karate).
  3. If VS Code asks whether you trust the publisher Karate Labs, choose Trust Publisher & Install.

VS Code may also offer to install the project's recommended extension; that is the same one.

4. Karate Setup​

The Karate Setup panel opens by itself, with the badge Not Installed.

  1. Click Install CLI. It downloads karate.exe to %LOCALAPPDATA%\Programs\Karate and adds that folder to your user PATH. No admin rights needed.
  2. Click Run Setup. A terminal runs karate setup --all, which downloads a Java runtime and Karate into %USERPROFILE%\.karate. You do not install Java yourself.
  3. When the terminal is done, click Refresh. The three cards (CLI Launcher, Java Runtime, Karate JAR) turn green and the badge reads Ready.

Reopen the panel at any time from the Command Palette: Karate: Setup.

5. Sign In​

  1. On the panel's License card (Not signed in), click Sign In. Your browser opens the karatelabs.io sign-in page.
  2. Sign in, copy the session id the page shows, and paste it into the input box in VS Code.
  3. The status bar changes from Karate: Sign In to your plan, for example Karate PRO.

The license is saved to %USERPROFILE%\.karate\karate.lic, so you sign in once. See License Activation for renewing and offline licenses.

6. Write and Run​

  1. Open the Testing view (the flask icon). It lists every feature in the project. Open features\cart\cart.feature.
  2. Click ▶ in the gutter next to a Scenario, or put the cursor in it and press Ctrl+F5. Results appear in the Test Explorer as each scenario finishes.
  3. Hover a row of the Examples table and click Run >> to run that row alone.

With IDE Pro, keywords complete as you type and mistakes such as = instead of == in a match are underlined before you run. Format Document (Shift+Alt+F) lines up Examples tables.

Windows Firewall

todos.feature starts a local mock server, so the first run of it may raise a Windows Defender Firewall prompt. cart.feature starts no server.

7. Debug a Failing Test​

The video debugs a failing test. To see the same failure:

  1. In features\cart\invoice.js, line 3, change item.price * item.qty to item.price and save.
  2. Run the Scenario in cart.feature. It fails: match failed: EQUALS, a subtotal of 7 where 11 is expected.
  3. In invoice.js, click the gutter at line 4 to set a breakpoint.
  4. In cart.feature, right-click the gutter ▶ → Debug Test. Execution pauses inside invoice.js; the Variables view shows items, taxRate and subtotal.
  5. In the Debug Console, evaluate items[0].price * items[0].qty: 6, while the changed line added only the price, 2.
  6. Stop debugging, restore item.price * item.qty, save and run again: green.

Debugging needs IDE Pro. See Debug for Java breakpoints and more.

8. Open the Report​

After a run, VS Code shows Karate test complete with an Open Report button. It opens target\karate-reports\karate-summary.html in your browser. Click a feature to see each step, with the failing step's error.

Keep the report open

Leave the feature's report page open while you work. After each fix and re-run, reload the page (F5) and watch red turn green, without navigating from the summary again.

If Windows asks which app should open the .html file, choose your browser and Always.

Prefer the Command Line?​

One line in PowerShell installs the Karate CLI. Like the extension, it needs no admin rights and adds karate to your user PATH:

PowerShell
irm https://karate.sh/install.ps1 | iex

Then, in a new terminal in the project folder:

PowerShell
karate setup --all
karate run

karate run runs everything under the paths in karate-pom.json and writes the report to target\karate-reports\karate-summary.html. It needs no sign-in. On macOS and Linux the install line is curl -fsSL https://karate.sh/install.sh | sh; that script does not run in Git Bash on Windows, so use the PowerShell line there. See karate.sh and Command Line.

Plans​

  • IDE Plus runs your tests in the editor: gutter ▶, Test Explorer, single Examples rows.
  • IDE Pro adds the debugger, keyword completion, live diagnostics, folding, JSON code actions and Xplorer Premium.
  • Enterprise adds async API testing, concurrent licenses and the license management portal.

See karatelabs.io/pricing.

Next Steps​