No results for

Powered byAlgolia

toHaveValidJson( )


expect.js library is no longer maintained

expect.js library has been deprecated in favor of Chaijs.

Please migrate to the k6Chaijs library. The documentation below is retained for historical reasons.

toHaveValidJson() validates that the http response has valid JSON body. It must be called in the chain after the t.expect(response) or .and(response).

When toHaveValidJson() returns false, the chain is broken, and the test is marked as failed. When the chain is broken, further checks inside of the test are omitted.


FunkFunk object


import { describe } from '';
import http from 'k6/http';
export default function testSuite() {
describe('Basic test', (t) => {
const response = http.get('');
.as('number of crocs')