Files
bruno/packages/bruno-tests/collection/scripting/inbuilt modules/tv4/tv4.bru
2025-05-07 17:44:29 +05:30

40 lines
580 B
Plaintext

meta {
name: tv4
type: http
seq: 1
}
post {
url: {{host}}/api/echo/json
body: json
auth: inherit
}
body:json {
{
"name": "John",
"age": 30
}
}
tests {
const tv4 = require("tv4")
const schema = {
type: 'object',
properties: {
name: { type: 'string' },
age: { type: 'number' }
}
};
let responseData = res.getBody();
let isValid = tv4.validate(responseData, schema);
test("Response body matches expected schema", function () {
expect(isValid, tv4.error ? tv4.error.message : "").to.be.true;
});
}