Yup for validating JSON schema. #166
-
👋🏻 Hello. In the API docs I found There is a workaround Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @b12k, Welcome to PactumJS Discussions. There are different ways we can bring our own custom assertion mechanisms. expectexpect method allows us to run some custom code to validate the response. const { spec } = require('pactum');
const { object, string, number } = require('yup');
const user_schema = object({
name: string().required(),
age: number().required().positive().integer()
});
await spec()
.get('https://randomuser.me/api')
.expect(ctx => {
user_schema.validateSync(ctx.res.json);
}); setJsonSchemaAdaptersetJsonSchemaAdapter allows us to update the inbuilt json schema adapter to use a custom defined adapter. Some additional work needs to be done to properly configure the new custom adapter. |
Beta Was this translation helpful? Give feedback.
Hello @b12k, Welcome to PactumJS Discussions.
There are different ways we can bring our own custom assertion mechanisms.
expect
expect method allows us to run some custom code to validate the response.
setJsonSchemaAdapter
setJsonSchemaAdapter allows us to update the inbuilt json schema adapter to use a custom defined adapter. Some additional work needs to be done to properly c…