supertest icon indicating copy to clipboard operation
supertest copied to clipboard

Add server response log when status code error

Open WarleyGabriel opened this issue 3 years ago • 4 comments

This pull request solve this issue: https://github.com/visionmedia/supertest/issues/631

WarleyGabriel avatar Feb 01 '21 19:02 WarleyGabriel

I think this would be a pretty big breaking change, hmm

niftylettuce avatar Feb 01 '21 19:02 niftylettuce

Pull Request Test Coverage Report for Build 495

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 97.447%

Totals Coverage Status
Change from base Build 493: 0.0%
Covered Lines: 146
Relevant Lines: 150

💛 - Coveralls

coveralls avatar Feb 01 '21 19:02 coveralls

Why would this be a breaking change? It makes the assertions more useful for debugging, but does not affect the assertion itself. A test that does not pass will continue not passing, but now with more info

danilofuchs avatar Jul 02 '21 17:07 danilofuchs

I think this is a breaking change because one would normally expect the error messages to be much shorter.

I also think that stringifying the body in the message is probably bad practice, as the body could be a huge response payload (e.g. HTML by accident instead of JSON). I think perhaps declaring the error, e.g. const err = new Error(...) and then making a private property on it, such as err._res = res would be more useful.

niftylettuce avatar Jan 05 '22 17:01 niftylettuce

Since this is not gonna be merged, closing it.

WarleyGabriel avatar Dec 16 '22 13:12 WarleyGabriel

This should be a new PR, and as suggested, there should be another property on the error object.

We suggest to add both err.response and err.response_stringified.

Also this will be a breaking change, since some may have tests written that explicitly check the err object for certain values and properties.

titanism avatar Dec 16 '22 20:12 titanism

We would merge this if you submitted a new PR with suggestions above @WarleyGabriel. Thank you 🙏

titanism avatar Dec 16 '22 20:12 titanism