notpresent 关键字在空手道中不起作用

The notpresent keyword is not working in Karate

我试图断言 JSON 响应中没有密钥。这是回应

   {
    "_type": "UserAccount",
    "accountName": "Account_Name",
    "accountType": "regular",
    "whiteList": true,
    "sfAccountId": "1",
    "preferredLanguage": "english",
    "imageSize": "highRes",
    "_id": "775a8451-6a07-42da-a199-fe98f44bdc06"
}

我已经根据文档尝试了这两个步骤 karate#null-and-notpresent and this answer from

And match response.appClientId == '#notpresent'
And match response == {appClientId:'#notpresent'}

然而,这是我在上面的第一步中不断遇到的错误

com.jayway.jsonpath.PathNotFoundException: No results for path: $['appClientId']

第二步

com.intuit.karate.KarateException: path: $, actual

提前致谢

也许你的版本已经过时了,下面的版本适用于我的 0.9.1:

* def response =
"""
{
    "_type": "UserAccount",
    "accountName": "Account_Name",
    "accountType": "regular",
    "whiteList": true,
    "sfAccountId": "1",
    "preferredLanguage": "english",
    "imageSize": "highRes",
    "_id": "775a8451-6a07-42da-a199-fe98f44bdc06"
}
"""
* match response.appClientId == '#notpresent'
* match response contains { appClientId: '#notpresent' }