我需要获取当前确切的集合变量值。
在邮递员请求的预请求脚本中,我设置了2 个集合变量,如下所示
pm.collectionVariables.set("firstCollectionVariable", "string_{{$guid}}");
pm.collectionVariables.set("secondCollectionVariable", "second_variable_{{firstCollectionVariable}}");
然后我在发布请求正文中使用这两个集合变量来设置特定数据,如下所示
{
"firstKey": {{firstCollectionVariable}},
"secondKey" : {{secondCollectionVariable}},
}
firstKey 和 secondKey 按预期设置
firstKey => "string_c6631d2c-2427-4903-b604-8120662a5e0e"
secondKey => "second_variable_string_c6631d2c-2427-4903-b604-8120662a5e0e"
问题是当我尝试使用检查响应时
pm.expect(pm.response.secondKey).to.eql(pm.collectionVariables.get("secondCollectionVariable"));
我得到断言错误
AssertionError:预期“second_variable_string_c6631d2c-2427-4903-b604-8120662a5e0e”深度等于“second_variable_{{firstCollectionVariable}}”
如何获得集合变量的当前确切值?