The Tavern documentation shows how to use an external function to perform custom validation on an entire response:
response:
status_code: 200
verify_response_with:
function: testing_utils:message_says_hello
There are also some built-in type validators to verify that specific fields of a response are of the correct type:
response:
body:
date: !anystr
How can I define a custom function that validates a single value within the response header or body?
Some use cases:
- Validate a JSON Web Token that's embedded within a response
- Verify that date strings are of the expected form
- Verify that a field contains a valid email address or phone number
Aucun commentaire:
Enregistrer un commentaire