NarendraR
NarendraR

Reputation: 7708

JavaScript toString() method is not working for JSON in karate v 1.1.0

In karate version 0.9.6 the following code was working fine

* def response = { "firstName": "John", "lastName" : "doe", "age"      : 26, "address"  : { "streetAddress": "applewood", "city"         : "Nara", "postalCode"   : "630-0192" } }
* match response.toString() contains 'applewood'

But in karate version 1.1.0, The assertion failing with:

match failed: CONTAINS
$ | actual does not contain expected (STRING:STRING)
'[object Object]'
'applewood'

classpath:...some classpath

Even I printed the response.toString() and its printing [object Object].

Is there any change in JS function support in karate feature files in v1.1.0?

Upvotes: 2

Views: 1070

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

You can try this change:

* match karate.toString(response) contains 'applewood'

A couple more points:

Upvotes: 3

Related Questions