Skip to content

[BUG]: JSON attachments are not pretty printed as in native HTML report #203

@AdamOakman

Description

@AdamOakman

Describe the bug
JSON attachments are not pretty-printed as in native HTML report. More-over when some unspecified number of characters is exceeded the JSON file is only available for download as extension-less file instead of printing all its contents (for example 31 kB JSON attachments is only downloadable) which is far from being ideal.

To Reproduce

testInfo.attachments.push({
   name: 'Generated API Requests',
   contentType: 'application/json',
   body: Buffer.from(JSON.stringify(global.generatedClientsRequestsTestLevel, null, 2))
});

Expected behavior
JSON attachments (big ones as well) should be pretty-printed or include space indentations as in the passed body and always be visible in the report without having to download them. See below screenshot how it works in native HTML report:
Image

Screenshots
Big files (it should still be possible to display its contents on the fly without having to download the file):
Image
Small files (JSONs not pretty printed):
Image

Setup information:
System:
OS: Windows 11 10.0.26100
CPU: (12) x64 Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
Memory: 7.52 GB / 31.73 GB
Binaries:
Node: 22.16.0 - C:\nvm4w\nodejs\node.EXE
npm: 10.8.2 - ~\AppData\Roaming\npm\npm.CMD
IDEs:
VSCode: 1.100.2 - C:\Program Files\Microsoft VS Code\bin\code.CMD
Languages:
Bash: 5.1.16 - C:\WINDOWS\system32\bash.EXE
npmPackages:
@playwright/test: 1.54.1 => 1.54.1

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions