Pretty print passed in order and schema validation errors in thrown assertion
This commit is contained in:
parent
fa559377c8
commit
ae47981669
@ -22,8 +22,10 @@ export const assert = {
|
||||
const schemaValidator = new SchemaValidator();
|
||||
const validationResult = schemaValidator.validate(value, schema);
|
||||
const hasValidationErrors = validationResult.errors.length > 0;
|
||||
const assertMsg = `Expected ${variableName} to conform to schema ${schema.id}, encountered: $value`;
|
||||
this.assert(!hasValidationErrors, assertMsg);
|
||||
const msg = `Expected ${variableName} to conform to schema ${schema.id}
|
||||
Encountered: ${JSON.stringify(value, null, '\t')}
|
||||
Validation errors: ${validationResult.errors.join(', ')}`;
|
||||
this.assert(!hasValidationErrors, msg);
|
||||
},
|
||||
assert(condition: boolean, message: string) {
|
||||
if (!condition) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user