Skip to content

fix(html): don't treat user stdout/stderr attachments as console output - #43558

Open
Ishaan (guptaishaan) wants to merge 1 commit into
microsoft:mainfrom
guptaishaan:fix-43555
Open

Ishaan (guptaishaan) wants to merge 1 commit into
microsoft:mainfrom
guptaishaan:fix-43555

Conversation

@guptaishaan

Copy link
Copy Markdown

Fixes #43555

_serializeAttachments() in the HTML reporter treats every text/plain attachment named stdout or stderr as captured console output and runs stripAnsiEscapes(a.body as string). User attachments with those names have a Buffer body (or no body with path), so the call threw TypeError and a passing run exited with code 1.

The fix adds typeof a.body === 'string' to the condition. Console output attachments always have a string body, so only they take the merge and strip branch. User attachments take the normal path.

Test: extended reporter-html.spec.ts with a case attaching stdout (body) and stderr (path). It fails before the fix with str.replace is not a function and passes after, in both created and merged report modes.

Verified on Linux only. Three git-related tests in reporter-html.spec.ts fail in my sandbox with and without this change. I ran the new test with a downloaded Chromium in place of the chrome channel, which is not installed here.

Thanks to fizzbeom (@fizzbeom) for the report, the repro and the suggested fix.

The HTML reporter merged and ANSI-stripped every text/plain attachment
named stdout or stderr, assuming a string body. User attachments with
those names have a Buffer body or only a path, so stripAnsiEscapes
threw and a passing run exited with code 1.

Only handle attachments with a string body that way. User attachments
now go through the regular attachment path.

Fixes microsoft#43555

This branch has not been deployed

No deployments
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.

[Bug]: HTML reporter crashes when a test attaches a file named "stdout" or "stderr"

1 participant