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

fix: assertion log limit #2485

Merged
merged 8 commits into from Oct 27, 2023

Conversation

sgoossens
Copy link
Contributor

@sgoossens sgoossens commented Dec 12, 2022

Purpose (TL;DR) - mandatory

Allow for a log limit setting on the assertion object, that when true, will truncate the error.message that is returned via a failing assertion. The limit for the log message will be set to a default if none was provided

#2484

Background (Problem in detail) - optional

When a stubbed method has a large property on it, it is logged in the failing assertion causing runoff in the terminal and making it hard to see what assertion actually failed.

By allowing for a log limitation setting and a default log limit, error logs can be truncated.

How to verify - mandatory

  1. use this app and point the sinon instance to this version
  2. see the logs are reduced when the setting is on

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

@sgoossens sgoossens force-pushed the feat/allow-limit-to-assertion-logs branch 2 times, most recently from 6709870 to 82aaaba Compare December 12, 2022 21:31
Copy link
Contributor

@fatso83 fatso83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test coverage. ✌️

lib/sinon/assert.js Outdated Show resolved Hide resolved
@fatso83
Copy link
Contributor

fatso83 commented Aug 9, 2023

Would you be interested in help getting it over the finish line? Have some time these days.

@sgoossens
Copy link
Contributor Author

Would you be interested in help getting it over the finish line? Have some time these days.

Sure that would be great. I lost track of this but think it would be a great add. I can also put some time in to addressing your feedback as well

@fatso83 fatso83 force-pushed the feat/allow-limit-to-assertion-logs branch from 82aaaba to 351d630 Compare October 25, 2023 18:35
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8dbfd02) 96.03% compared to head (7701afc) 96.05%.
Report is 4 commits behind head on main.

❗ Current head 7701afc differs from pull request most recent head ef5c456. Consider uploading reports for the commit ef5c456 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2485      +/-   ##
==========================================
+ Coverage   96.03%   96.05%   +0.02%     
==========================================
  Files          40       41       +1     
  Lines        1915     1928      +13     
==========================================
+ Hits         1839     1852      +13     
  Misses         76       76              
Flag Coverage Δ
unit 96.05% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
lib/create-sinon-api.js 100.00% <100.00%> (ø)
lib/sinon.js 100.00% <100.00%> (ø)
lib/sinon/assert.js 100.00% <100.00%> (ø)
lib/sinon/colorizer.js 100.00% <ø> (ø)
lib/sinon/create-sandbox.js 100.00% <100.00%> (ø)
lib/sinon/sandbox.js 97.90% <100.00%> (+<0.01%) ⬆️
lib/sinon/spy-formatters.js 98.55% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fatso83 fatso83 mentioned this pull request Oct 25, 2023
2 tasks
@fatso83
Copy link
Contributor

fatso83 commented Oct 25, 2023

OK, so I added test coverage, fixed up some logical errors, exposed the options on the sandbox creation, etc.

This is ready for merge from my perspective, but it does not change the default, as that would be a breaking change, but we can do that with version 18 . It still allows creating sandboxes with log limits, which is probably what you want right now.

The way I stubbed out

@fatso83
Copy link
Contributor

fatso83 commented Oct 27, 2023

@sgoossens You ok with this? Anything to add/change?

Copy link
Contributor Author

@sgoossens sgoossens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great thank you for helping get this over the line

lib/sinon/assert.js Outdated Show resolved Hide resolved
@fatso83 fatso83 merged commit f7d180c into sinonjs:main Oct 27, 2023
7 checks passed
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.

None yet

3 participants