eHealthAfrica / data-models-deprecated

Validation for standard data models
Apache License 2.0
4 stars 8 forks source link

Pretty print validation errors in test runner #20

Closed tlvince closed 9 years ago

tlvince commented 9 years ago

Currently, if there's a validation error, the test runner (mocha) logs the error as minified JSON. Since this is meant to be human-readable, it should be pretty printed.

> mocha --watch                                                                                                                                                   [0/409]

child_process: customFds option is deprecated, use stdio instead.

  nutrition-survey
    1) validates the first example

  0 passing (109ms)
  1 failing

  1) nutrition-survey validates the first example:
     AssertionError: [{"code":"PARENT_SCHEMA_VALIDATION_FAILED","params":[],"message":"Schema failed to validate against its parent schema, see inner errors for details.
","path":"#/","inner":[{"code":"ANY_OF_MISSING","params":[],"message":"Data does not match any schemas from 'anyOf'","path":"#/definitions/team/properties/members/items"
...
tlvince commented 9 years ago

Invalid: just set stringify options in the spec, e.g.:

assert.equal(errors, null, JSON.stringify(errors, null, 2));