How to do schema validation


I think K6 is an awesome tool for automation REST API tests.

It supports checking of response HTTP codes & content, but I’m seems to be missing the option to validate the response with a JSON schema?

Is it possible with the default available checks or should I look for other libraries (like to check the response?

Hi @thim81,

welcome to the forums.

Regarding your first question, I should say that the main goal for writing k6 is performance testing. Although it may fit in RESTful API testing category, but that’s not the main reason for k6 existence. Thus it doesn’t provide any kind of schema validation out of the box. BTW, this is what Postman uses in its sandbox API: tv4.

The biggest upside to using JavaScript for writing (load) test scripts, beside being easy-to-use, is that you might be able to include another JS library in your code, as long as it doesn’t use native NodeJS or browser APIs.

For this to work, have a look at the modules documentation in k6 docs.