#3046·karate

2.1.2: driver.script adds an extra invocation to an arrow IIFE

Author: sentrybottaleCreated Sep 15, 2026Updated Sep 17, 2026
Labelsbugfixed

Description

driver.script() adds another invocation around an arrow-function expression that already invokes itself. Returning a boolean or object then fails because that result is not callable. An ordinary function expression and a plain browser expression work.

This reproduces on about:blank, without an application, authentication or configuration file.

Steps to Reproduce

Install Chrome, place the official standalone JAR in an empty directory, and save this as repro.feature:

gherkin
Feature: Browser arrow function evaluation
Scenario: Evaluate an already-invoked arrow function once
* configure driver = { type: 'chrome', headless: true }
* driver 'about:blank'
* def actual = driver.script('(() => { return true; })()')
* match actual == true

Run java -jar karate-2.1.2.jar run repro.feature.

Compare the unchanged feature with java -jar karate-1.5.2.jar repro.feature.

Expected Behavior

The supplied expression executes once, returns true, and the scenario passes.

Actual Behavior

2.1.2 fails with TypeError: (intermediate value)(...) is not a function.

Its log shows that this expression was sent for execution:

javascript
((() => { return true; })())()

The added final () attempts to call the boolean returned by the original expression. An arrow expression returning {value: 42} fails the same way.

Control results:

Expression 2.1.2 1.5.2
(() => { return true; })() Fail Pass
(() => { return {value: 42}; })() Fail Pass
(function(){ return true; })() Pass Pass
document.body != null Pass Pass

Each expression is assigned using def, then its result is matched separately.

Karate Version

2.1.2 standalone; comparison 1.5.2.

Java Version

Oracle Java 24.0.2.

Operating System

macOS ARM64; Google Chrome 153.0.8010.37, headless Chrome/CDP driver.