ramlev
ramlev copied to clipboard
Clean up validation outputs
trafficstars
Currently, the outputs of validation is raw mocha results, it's a bit verbose.
Like,
21) /repos/{ownerId}/{repoId}/milestones POST response 201:
AssertionError: Got unexpected response body:
{
"url": "https://api.github.com/repos/octocat/Hello-World/milestones/1",
"number": 1,
"state": "open",
"title": "v1.0",
"description": "",
"creator": {
"login": "octocat",
"id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.github.com/users/octocat"
},
"open_issues": 4,
"closed_issues": 8,
"created_at": "2011-04-10T20:09:31Z",
"due_on": null
}
Error: expected value to match json-schema '{"$schema":"http://json-schema...' -> '{"url":"https://api.github.com...'
invalid type: null (expected string)
schema: {"$schema":"http://json-schema.org/draft-03/schema","type":"...
rule: /properties/due_on/type -> "string"
field: /due_on -> null: null
at Function.assert.jsonSchema (/usr/local/lib/node_modules/ramlev/node_modules/chai-json-schema/index.js:176:40)
at Test.assertExample (/usr/local/lib/node_modules/ramlev/lib/test.js:77:21)
at Test.assertExample (/usr/local/lib/node_modules/ramlev/lib/test.js:3:61)
at Test.run (/usr/local/lib/node_modules/ramlev/lib/test.js:56:21)
at Object.suite.addTest.Mocha.Test._.bind.test (/usr/local/lib/node_modules/ramlev/lib/test-runner.js:37:19)
at Test.Runnable.run (/usr/local/lib/node_modules/ramlev/node_modules/mocha/lib/runnable.js:217:15)
at Runner.runTest (/usr/local/lib/node_modules/ramlev/node_modules/mocha/lib/runner.js:373:10)
at /usr/local/lib/node_modules/ramlev/node_modules/mocha/lib/runner.js:451:12
at next (/usr/local/lib/node_modules/ramlev/node_modules/mocha/lib/runner.js:298:14)
at /usr/local/lib/node_modules/ramlev/node_modules/mocha/lib/runner.js:308:7
Places can improve:
- [ ] Remove error stack
- [ ] Locate the line # of invalid example in RAML
- [ ] Better error output for json
I'd suggest at least allowing for an option to be set that displays the entire schema instead of only the first tiny bit. That may help debug issues where the schema has been written incorrectly.
Agree