From ae47981669e4c471623f22f8ecee93709dfe47bd Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 25 May 2017 12:08:21 +0200 Subject: Pretty print passed in order and schema validation errors in thrown assertion --- src/ts/utils/assert.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/ts/utils') diff --git a/src/ts/utils/assert.ts b/src/ts/utils/assert.ts index 7fb51fbdc..972047118 100644 --- a/src/ts/utils/assert.ts +++ b/src/ts/utils/assert.ts @@ -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) { -- cgit v1.2.3