-
Notifications
You must be signed in to change notification settings - Fork 125
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
[newman-reporter-allure] Fix: Resolved the issue of formatting in JSON response content displaying in Allure reports. #808
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution, good job here!
Please, provide unit-tests for the changes to continue with the PR.
const attachment = this.allureRuntime.writeAttachment(response.body, { | ||
contentType: ContentType.TEXT, | ||
contentType: contentType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leave the property without shadow:
{ contentType }
let contentType = ContentType.TEXT; | ||
|
||
// Check if the response content type is JSON | ||
const contentTypeHeader = args.item.responses.members[0]?.getHeader('Content-Type'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set empty string as fallback value to eliminate nullish checks
|
||
// Check if the response content type is JSON | ||
const contentTypeHeader = args.item.responses.members[0]?.getHeader('Content-Type'); | ||
if (contentTypeHeader && contentTypeHeader.toLowerCase().includes('application/json')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok, but imo, better to use regexp:
/application\/json/i.test(contentTypeHeader)
66e46a4
to
92daa86
Compare
@epszaw Is there anything else that needs to be modified? edit: Correcting some typo errors. |
@win5923 please, check typescript errors and linters |
fc3ad9a
to
5616d17
Compare
…ying in Allure reports.
Fixed Property 'response' does not exist on type '{ item: Item; }'. |
…ying in Allure reports.
Context
When the
Content-Type
of a response body isapplication/json
, the formatting should be normal.Screenshot
Postman:
Postman Response body:
Allure report (anonymised for privacy):
Checklist