0

I am using Postman and its built-in Json schema validator library (tv4). There are many earlier posts on the same issue and yet I see that only in some cases issue is resolved. Here is my Test Script code:

var data = JSON.parse(responseBody);
console.log("<---data: ", data)
var schema = postman.getGlobalVariable('mySchema')
console.log("<---schema: ", schema)
var result = tv4.validateMultiple(data, schema, false, true);
tests['Schema is valid'] = result['valid'] === true
console.log("<---errors: ", JSON.stringify(result['errors']))

No matter what schema value I pass, the Test always passes.

NKM
  • 602
  • 1
  • 6
  • 18

1 Answers1

0

When I use minified JSON in the global variable and then parse it in test script then it works. Don't understand why is that so.

JSON.parse(postman.getGlobalVariable('mySchema'))

NKM
  • 602
  • 1
  • 6
  • 18