Pretty print passed in order and schema validation errors in thrown assertion
This commit is contained in:
		@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user