在Karate 0.9.5.RC5中将Json对象作为def传递时,Object.keys(data)Js fu不起作用

时间:2019-12-11 16:19:07

标签: karate

  1. 具有以下功能的Js文件
function fn(config) {

 config.OAuth2 = function (data) {
   var keys = Object.keys(data);
   return keys;
 }
 return config;
}
  1. 具有以下步骤的功能文件
   Feature: Sample Feature

    Scenario Outline: Sample Scenario

    #This is works
    * def a = OAuth2({firstName: '<firstName>',lastName: '<lastName>'})
    * print a

    #This do not work
    And def req = {firstName: '<firstName>',lastName: '<lastName>'}
    * def b = OAuth2(req)
    * print b

    Examples:
      | firstName | lastName |
      | a         | a1       |
  1. 在var键处给出错误= Object.keys(data);
javascript evaluation failed: OAuth2(req), TypeError: {firstName=a, lastName=a1} is not an Object in <eval>

1 个答案:

答案 0 :(得分:0)

请不要使用Object.keys(),而应使用karate.keysOf()