Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat, test, refactor: more useful assertion failure msgs #67

Merged

Conversation

rwalle61
Copy link
Collaborator

feat:

  • assertion failure messages now much more informative and more consistent with each other (see comparison below)
  • changed some negated assertions to pass instead of fail.
    E.g. previously expect(res).to.not.satisfyApiSpec would fail if res matched no responses in your API spec. expect(res).to.not.satisfyApiSpec meant "expect res to match but not satisfy a response defined in your API spec".
    Now expect(res).to.not.satisfyApiSpec means "expect res to neither match nor satisfy a response defined in your API spec". So if res matches no responses in your API spec, then expect(res).to.not.satisfyApiSpec passes.

test:

  • added a few test cases
  • updated the test openapi specs correspondingly

refactor:

  • moved assertions into assertions dir
  • throw ValidationErrors instead of generic Errors
  • rather than pass error.message through to the user, construct a more informative message at the chai assertion layer.

Comparison: assertion failure messages now much more informative and more consistent with each other:
expect(response).to.satisfyApiSpec:
image

expect(object).to.satisfySchemaInApiSpec:
image

@rwalle61 rwalle61 force-pushed the more-useful-assertion-failure-msgs branch from 7b5ed78 to 23b1d78 Compare April 13, 2020 11:06
@codecov
Copy link

codecov bot commented Apr 13, 2020

Codecov Report

Merging #67 into master will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #67   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        15    +3     
  Lines          232       281   +49     
=========================================
+ Hits           232       281   +49     
Impacted Files Coverage Δ
lib/classes/AbstractResponse.js 100.00% <ø> (ø)
lib/assertions/satisfyApiSpec.js 100.00% <100.00%> (ø)
lib/assertions/satisfySchemaInApiSpec.js 100.00% <100.00%> (ø)
lib/classes/AbstractOpenApiSpec.js 100.00% <100.00%> (ø)
lib/classes/OpenApi2Spec.js 100.00% <100.00%> (ø)
lib/classes/OpenApi3Spec.js 100.00% <100.00%> (ø)
lib/classes/errors/ValidationError.js 100.00% <100.00%> (ø)
lib/index.js 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c165367...23b1d78. Read the comment docs.

@rwalle61 rwalle61 merged commit b7238c2 into openapi-library:master Apr 13, 2020
@rwalle61 rwalle61 deleted the more-useful-assertion-failure-msgs branch April 13, 2020 11:12
@rwalle61 rwalle61 mentioned this pull request Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant