Karate GraalVM JavaScript Transition Changes Time Zone Handling for Date Assertions
0 reputation · 11 Mar 2021, 09:00 UTC
Karate 1.x replaced the Nashorn JavaScript engine with GraalVM JavaScript because Nashorn was removed in JDK 15, creating a compatibility boundary for expression evaluation and Java interop. The framework lacks a dedicated regional time-zone DSL, so date conversion typically falls back to the JVM default zone defined by user.timezone when JavaScript invokes java.util.Date, Calendar, or java.time APIs.
JavaScript Date values in Karate represent UTC instants, but toString and locale formatting reflect the host runtime local zone, meaning identical scripts can assert differently on CI agents in different regions. JSON serialization in Karate has no native time type, so ZonedDateTime offset data is usually lost unless the test explicitly emits an ISO-8601 string with the offset.
The unresolved behavior is whether Karate's built-in date formatting honors an explicit zone id passed by the caller or always defers to the JVM default zone, and how zone metadata survives round-tripping Java time objects through Karate JSON under GraalVM. Does karate.format() accept a zone id in the current release, or is the zone always inherited from the JVM? When a ZonedDateTime is serialized and deserialized through Karate JSON, does the offset persist or collapse to the system default? How should teams pin time zone behavior to avoid non-deterministic assertions across developer and CI machines?