Karate cache persistence across scenarios and its impact on test reliability
0 reputation · 15 Feb 2020, 21:42 UTC
When Karate’s built‑in response cache is enabled with karate.configure('cache', true), identical requests return the stored response without contacting the server. The goal is to use this cache to speed up test execution while guaranteeing that each scenario sees the current state of the backend, even when the service modifies data during a suite run.
Because the cache is not automatically cleared between scenarios or features, there is uncertainty about whether stale responses can leak from one scenario to the next, potentially masking backend changes. The documentation does not define a cache‑invalidation policy, and behavior may vary between releases such as 0.9.x and 1.4.x, making it unclear what manual steps are required to isolate the cache per scenario without sacrificing the performance benefit.
Does Karate automatically clear the response cache between scenarios? If not, what is the recommended way to reset the cache for each scenario while keeping caching enabled? How does cache persistence across scenario boundaries differ between Karate 0.9.x and 1.4.x?