aboutsummaryrefslogtreecommitdiffstats
path: root/src/ts/utils
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-05-25 18:08:21 +0800
committerFabio Berger <me@fabioberger.com>2017-05-25 18:08:21 +0800
commitae47981669e4c471623f22f8ecee93709dfe47bd (patch)
tree1fa721da73dec93708fd7125de08f308f54615a4 /src/ts/utils
parentfa559377c80a75ba4169cab0825e5808154ae72b (diff)
downloaddexon-sol-tools-ae47981669e4c471623f22f8ecee93709dfe47bd.tar
dexon-sol-tools-ae47981669e4c471623f22f8ecee93709dfe47bd.tar.gz
dexon-sol-tools-ae47981669e4c471623f22f8ecee93709dfe47bd.tar.bz2
dexon-sol-tools-ae47981669e4c471623f22f8ecee93709dfe47bd.tar.lz
dexon-sol-tools-ae47981669e4c471623f22f8ecee93709dfe47bd.tar.xz
dexon-sol-tools-ae47981669e4c471623f22f8ecee93709dfe47bd.tar.zst
dexon-sol-tools-ae47981669e4c471623f22f8ecee93709dfe47bd.zip
Pretty print passed in order and schema validation errors in thrown assertion
Diffstat (limited to 'src/ts/utils')
-rw-r--r--src/ts/utils/assert.ts6
1 files changed, 4 insertions, 2 deletions
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) {