NagRock / ts-mockito

Mocking library for TypeScript
MIT License
969 stars 93 forks source link

objectContaining matcher to output object representation when a test fails #200

Closed srosato closed 3 years ago

srosato commented 3 years ago

Currently, when passing in an object with objectContaining which does not match the given value, the matcher's toString() method will return the object as an [object Object] representation. I modified the matcher and tests to be able to include the object's representation for easier debugging.

Given this code example: code-example

Using objectContaining with an object that does not match will output this: objectContaining

And with the fix: objectContaining-with-fix

codecov-commenter commented 3 years ago

Codecov Report

Merging #200 into master will increase coverage by 0.15%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #200      +/-   ##
==========================================
+ Coverage   93.55%   93.71%   +0.15%     
==========================================
  Files          34       34              
  Lines         652      652              
  Branches       80       80              
==========================================
+ Hits          610      611       +1     
+ Misses         30       29       -1     
  Partials       12       12              
Impacted Files Coverage Δ
src/matcher/type/ObjectContainingMatcher.ts 100.00% <100.00%> (+10.00%) :arrow_up:

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 6637048...f9ed256. Read the comment docs.

NagRock commented 3 years ago

Thanks