We have a 404 response that returns an empty response, but when trying to validate that, we get the following error. Is there a suggested way to evaluate a truly empty response?
* if (responseStatus == 404 ) matchResult = karate.match("$ == ''")
js failed:
>>>>
01: if (responseStatus == 404 ) matchResult = karate.match("$ == ''")
<<<<
org.graalvm.polyglot.PolyglotException: json string can not be null or empty
- com.jayway.jsonpath.internal.Utils.notEmpty(Utils.java:401)
- com.jayway.jsonpath.internal.ParseContextImpl.parse(ParseContextImpl.java:36)
- com.jayway.jsonpath.JsonPath.parse(JsonPath.java:647)
- com.intuit.karate.Json.of(Json.java:63)
- com.intuit.karate.core.ScenarioEngine.evalJsonPath(ScenarioEngine.java:2000)
- com.intuit.karate.core.ScenarioEngine.evalJsonPathOnVariableByName(ScenarioEngine.java:2053)
- com.intuit.karate.core.ScenarioEngine.evalKarateExpression(ScenarioEngine.java:2085)
Here is our response, which you can see is empty:
We have tried the following match test, with no luck.
* if (responseStatus == 404 ) matchResult = karate.match("$ == ''")
* if (responseStatus == 404 ) matchResult = karate.match("$ == []")
* if (responseStatus == 404 ) matchResult = karate.match("$ == '#[0]'")
* if (responseStatus == 404 ) matchResult = karate.match("$ == '#notpresent'")
* if (responseStatus == 404 ) matchResult = karate.match("$ == '#null'")
Reviewed the following github posts, with no luck: Karate Framework : #notnull and #present are not working in case response is empty Karate DSL blank response passes tests
Also tried a simple match, versus a karate match with the above evaluations, but those fail as well.
* match $ == []
json string can not be null or empty
* match $ == {}
json string can not be null or empty
* match $ == '#notpresent'
json string can not be null or empty