Skip to main content

GET STARTED

What's New in Karate v2

Karate v2 is a complete ground-up rewrite with significant improvements across the board. Most existing v1 tests work with just a dependency update — see the Migration Guide.

Performance & Scalability

Embedded JavaScript Engine

Karate v2 replaces GraalJS with a fast, hand-rolled JavaScript engine (karate-js) with ES6+ support, purpose-built for Java interop and thread-safe concurrent execution.

  • No GraalVM dependency — works on any Java 21+ JVM
  • Significantly faster for the Karate use-case (see benchmarks)
  • Thread-safe by design for parallel test execution

Virtual Threads (Java 21+)

Karate v2 requires Java 21+ and leverages virtual threads for massive parallelism with minimal overhead. This means you can run hundreds of scenarios in parallel without tuning thread pools.

@lock Tag

Scenario-level mutual exclusion for parallel safety:

@lock=database
Scenario: test that modifies shared state
# only one @lock=database scenario runs at a time

@lock=*
Scenario: exclusive test
# this scenario runs completely alone

Assertions & Test Data

match within

Assert that a numeric value falls within a range:

* match response.temperature within { low: 36.0, high: 37.5 }
* match response.score !within { low: 0, high: 50 }

karate.faker.*

Built-in test data generation — no external libraries needed:

* def name = karate.faker.firstName()
* def email = karate.faker.email()
* def id = karate.faker.randomInt()
* def phone = karate.faker.phone()

karate.expect() — Chai-style Assertions

Familiar BDD-style assertions for teams migrating from Postman or Mocha:

karate.expect(response.name).to.equal('John')
karate.expect(response.age).to.be.above(18)
karate.expect(response).to.have.property('email')
karate.expect(response.tags).to.include('active')

karate.uuid()

Generate random UUIDs:

* def id = karate.uuid()

Soft Assertions

Continue execution after match failures and aggregate all failures in the report:

* configure continueOnStepFailure = true
* match response.name == 'wrong' # recorded but doesn't stop
* match response.age == 999 # also recorded
* configure continueOnStepFailure = false

Modern HTTP Client

Apache HttpClient 5.6

Upgraded to Apache HttpClient 5.6 with Brotli compression support and improved connection management.

Declarative Auth

Centralized authentication configuration — no more writing custom karate-config.js headers functions for common auth patterns:

// Basic Auth
configure auth = { type: 'basic', username: 'user', password: 'pass' }

// Bearer Token
configure auth = { type: 'bearer', token: 'your-token' }

// OAuth2 Client Credentials (with automatic token refresh)
configure auth = {
type: 'oauth2',
tokenUrl: 'https://auth.example.com/token',
clientId: '...',
clientSecret: '...'
}

// OAuth2 Authorization Code (PKCE)
configure auth = {
type: 'oauth2',
flow: 'authorization_code',
authUrl: '...',
tokenUrl: '...',
clientId: '...'
}

// NTLM
configure auth = {
type: 'ntlm',
username: '...',
password: '...',
domain: '...',
workstation: '...'
}

Auth configuration is automatically inherited by called features, and OAuth2 tokens are refreshed automatically.

Mock Server Rewrite

The mock server has been completely rewritten with the new JS engine and a Netty-based HTTP server for improved performance. See Test Doubles and Mocking for details.

  • JavaScript file handlers as an alternative to feature files
  • Non-blocking response delays via Netty scheduler
  • Built-in CORS support

Gatling Integration

Re-implemented Gatling integration with a pure Java architecture. See Performance Testing for details.

  • Java-only DSL (no Scala required)
  • PerfHook integration for HTTP-level metrics
  • URI pattern matching for request grouping
  • Custom performance events for non-HTTP operations

Browser Automation

CDP Driver Rewrite

Complete reimplementation using Chrome DevTools Protocol directly — no WebDriver dependency needed for Chrome/Chromium/Edge.

Auto-wait

Automatic waiting before element operations reduces flaky tests. No more manual waitFor() calls for most interactions.

Browser Pooling

PooledDriverProvider automatically manages a pool of browser instances for parallel UI test execution:

Runner.path("features/")
.parallel(4); // pool of 4 drivers auto-created

Shadow DOM Support

CSS and wildcard locators now work inside Shadow DOM elements.

See UI Testing for complete browser automation documentation.

Developer Experience

Modern HTML Reports

Bootstrap 5.3 reports with dark mode, interactive tag filtering, and timeline view for parallel execution visualization.

JSONL Event Streaming

Memory-efficient karate-events.jsonl format with real-time progress for integration with external reporting tools:

Runner.path("features/")
.outputJsonLines(true)
.parallel(5);

JUnit 6 Integration

Streaming dynamic test generation via @TestFactory for better IDE integration:

<dependency>
<groupId>io.karatelabs</groupId>
<artifactId>karate-junit6</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>

Unified Event System

Single RunListener API for observing and controlling test execution — replaces the multiple hook interfaces in v1.

More Improvements

  • ANSI colors in console output, works even outside IDE
  • JavaScript debugging is now possible
  • Large JSON operations (e.g., contains) use disk when needed to avoid out-of-memory issues
  • cURL export for HTTP requests

V1 Compatibility

Karate v2 includes backward compatibility shims that allow most v1 code to work with minimal changes. The com.intuit.karate package delegates to the v2 implementation.

See the Migration Guide for step-by-step upgrade instructions.

Commercial & Enterprise

Karate Labs offers commercial tools that complement the open-source framework:

  • Karate Xplorer — Desktop IDE with Postman emulation and step-through debugging
  • Karate Agent — AI-powered browser testing via LLM agents
  • IDE Plugins — IntelliJ and VS Code extensions with debugging support
  • WebSocket Testing — Commercial module for async protocol testing

See Enterprise & Commercial for details, or visit karatelabs.io.