Closed aolson58 closed 7 years ago
I didn't see anything in the documentation supporting this syntax and attempted to exhaust the stack overflow threads as well
@aolson58 Test scripts in Postman are written in ES5 Javascript. I had a look at JSONPath, and it looks like it is made for Java, so we do not (cannot) support this as of now. You do have access lodash in the test scripts, so you could use that to do your filtering :)
It exists jsonpath libraries for javacript since years: https://github.com/s3u/JSONPath https://github.com/dchester/jsonpath
It looks like there is JsonPath for Javascript https://www.npmjs.com/package/jsonpath http://goessner.net/articles/JsonPath What does it take to make it work in Postman?
example json response
{ "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 10 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } ], "bicycle": { "color": "red", "price": 19.95 } }, "expensive": 10 }
I would expect a test like
tests['test name'] = jsonData.store.book[?(@.price == 10)].title == 'Sayings of the Century' to return me pass but instead postman returns "There was an error in evaluating the test script: Unexpected token ?
Is there some syntax that I am missing or is this not supported