newman icon indicating copy to clipboard operation
newman copied to clipboard

Added flag to set verbose output size limit for newman run

Open Sid200026 opened this issue 4 years ago • 9 comments

Flag for Verbose Output Size Limit

Previously, the output limit when the verbose flag was set was 2KB or 2048 bytes which were hardcoded in the codebase. The main argument that can be made for hardcoding the limit to 2KB is large data streams can crash the terminal. However, this limit is unfair in cases when the output size is just beyond the 2KB size limit. Moreover in cases when you want to pipe the output of newman run to a file, setting a size limit doesn't make sense and moreover, the terminal won't crash.

This PR adds two new flags under --reporter-cli-*

  1. --reporter-cli-verbose-output-limit : Specify the truncation size of body in verbose CLI output for requests and responses
  2. --reporter-cli-no-verbose-output-limit : This removes any truncation size limit of body in verbose CLI output for requests and responses

Syntax

newman run <collection> --verbose --reporter-cli-verbose-output-limit  <size in any unit>
newman run <collection> --verbose --reporter-cli-no-verbose-output-limit

Changes

  • [x] Modified cli core logic
  • [x] Added tests
  • [x] Updated Documentation

Closes #2845

Sid200026 avatar Dec 08 '21 21:12 Sid200026

Codecov Report

Merging #2883 (a66db04) into develop (90f4449) will increase coverage by 0.59%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2883      +/-   ##
===========================================
+ Coverage    90.96%   91.55%   +0.59%     
===========================================
  Files           21       21              
  Lines         1151     1161      +10     
  Branches       349      352       +3     
===========================================
+ Hits          1047     1063      +16     
+ Misses         104       98       -6     
Flag Coverage Δ
cli 82.77% <100.00%> (+0.67%) :arrow_up:
integration 40.74% <7.14%> (-0.27%) :arrow_down:
library 58.13% <7.14%> (-0.42%) :arrow_down:
unit 74.50% <7.14%> (-0.57%) :arrow_down:

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

Impacted Files Coverage Δ
bin/util.js 100.00% <ø> (ø)
lib/reporters/cli/index.js 87.43% <100.00%> (+3.83%) :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 90f4449...a66db04. Read the comment docs.

codecov[bot] avatar Dec 08 '21 22:12 codecov[bot]

@shamasis can you provide me with some additional feedback so that I can continue working on this?

Sid200026 avatar Dec 15 '21 07:12 Sid200026

Hey @shamasis, @codenirvana @coditva, I have updated this PR with the necessary changes.

Currently there are 2 flags,

  1. newman run <collection> --verbose --reporter-cli-verbose-output-limit <size in any unit>
  2. newman run <collection> --verbose --reporter-cli-no-verbose-output-limit

The --reporter-cli-verbose-output-limit uses bytes to convert string input to bytes. In case of any invalid input, a warning is shown and a fallback size of 2KB is used.

Sid200026 avatar Jan 11 '22 16:01 Sid200026

@shamasis, I have simplified the implementation by using a single flag.

newman run <collection> --verbose --reporter-cli-truncate-body-output <size in any unit>. You can pass infinite to remove any truncation limit.

Sid200026 avatar Jan 23 '22 17:01 Sid200026

@shamasis, I have simplified the implementation by using a single flag.

newman run <collection> --verbose --reporter-cli-truncate-body-output <size in any unit>. You can pass infinite to remove any truncation limit.

I think this is ready for approval. Feature now looks cool.

I've marked it as approved, but there's one tiny comment to resolve for you.

shamasis avatar Jan 24 '22 05:01 shamasis

Hello, this improvement is waiting for 1 year already, is there an eta when it'll be published or is there an alternative to avoid output limiting?

dronky avatar Dec 12 '22 16:12 dronky

I would love to have this

jmarcher avatar Jul 06 '23 13:07 jmarcher

Hello,

Is there any forecast to have this option published on newman? That's really something that will help a lot everyone, have the full request / response body written into a log. We work with images base64 inside the body and is impossible to check if everything was sent as expected

Eduardo

egbastos666 avatar Jan 03 '24 16:01 egbastos666