【问题标题】:TypeError: karate.map is not a function - KarateTypeError: karate.map 不是函数 - 空手道
【发布时间】:2018-11-30 10:12:11
【问题描述】:

在使用空手道地图比较 XML 和 JSON 响应时,如果我在下面运行我得到的代码,TypeError: karate.map is not a function。这和我之前的question.有关

我尝试搜索类似的问题,但没有找到任何问题。

* def json = 
 """
 {
  "Main": {
  "Cd":"ABC",
  "descriptionTxt":"Sample Main",
  "type":"A",
  "codeType":"P",
  "dt":"2018-10-15T00:00:00-05:00",
  "validity":"3",
  "segment":"Personal"
 },
  "testList":[
  {
     "code":"123",
     "descriptionTxt":"My Description",
     "categoryCd":"DUDU"
  },
  {
     "code":"675",
     "descriptionTxt":"His Description"
  },
  {
     "code":"345",
     "descriptionTxt":"Your Description",
     "categoryCd":"BH"
  }]
 }
 """

* def xml = 
"""
<ns4:root xmlns:ns4="http://foo.com" xmlns:ns5="http://bar.com">
 <ns4:Test>
  <ns5:code>123</ns5:code>
  <ns5:description>My Description</ns5:description>
  <ns5:categoryCode>DUDU</ns5:categoryCode>
  <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
 </ns4:Test>
 <ns4:Test>
  <ns5:code>345</ns5:code>
  <ns5:description>Your Description</ns5:description>
  <ns5:categoryCode>BH</ns5:categoryCode>
 </ns4:Test>
 <ns4:Test>
  <ns5:code>675</ns5:code>
  <ns5:description>His Description</ns5:description>
  <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
 </ns4:Test>
</ns4:root>
"""

* def list = /xml/root/Test
* def fun = function(x){ return { code: xpath(x, '/code'), descriptionTxt: xpath(x, '/description'), categoryCd: xpath(x, '/categoryCode') } }
* def temp = karate.map(list, fun)
* print temp
* print json.testList
* match json.testList contains temp

错误响应

Caused by: javax.script.ScriptException: TypeError: karate.map is not a function in <eval> at line number 1

请帮忙!

【问题讨论】:

    标签: karate


    【解决方案1】:

    很确定您使用的是旧版本的空手道。你确定你使用的是 0.8.0 吗?

    尝试升级。

    如果还是卡住,请按照这个流程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-29
      • 2020-06-17
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      • 2021-06-05
      相关资源
      最近更新 更多