-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
feat(reporter): report TestStep#attachments
#34037
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
TestStep#attachments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -393,3 +391,48 @@ test('should show custom fixture titles in actions tree', async ({ runUITest }) | |||
/After Hooks[\d.]+m?s/, | |||
]); | |||
}); | |||
|
|||
test('attachments tab shows all but top-level .push attachments', async ({ runUITest }) => { |
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.
This test shows a real regression from this change. As intended, test.info().attachments.push
will no longer show up as an action. The trace viewer only stores attachments in AfterActionTraceEvent
though. So top-level attachments, which live outside of an action, no longer show up in traces.
I don't think we'll want to merge a regression like this, so i'll make an exception for top-level attachment.push
calls, and emit them as actions to the trace viewer.
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.
Sounds fine for now. I see that's already done in the testInfo.ts
?
We can follow up by adding a timestamp to attachments and emitting a separate "testend" event in the trace with all the leftover attachments. At that point we can possibly remove "attach foo" steps as well. Up for discussion.
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.
Yes, that's already done 👍 Separate event post execution sounds good.
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.
Thanks for the review, that was super useful! I've addressed the feedback. I also had another look at what this change means for the trace viewer. There was a problem with top-level attachments that would have gone missing from the trace-viewer - added a workaround for that, see comment above.
Please have another look!
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -566,7 +566,7 @@ test('should opt out of attachments', async ({ runInlineTest, server }, testInfo | |||
'After Hooks', | |||
]); | |||
expect(trace.actions[1].attachments).toEqual(undefined); | |||
expect([...trace.resources.keys()].filter(f => f.startsWith('resources/'))).toHaveLength(0); | |||
expect([...trace.resources.keys()].filter(f => f.startsWith('resources/'))).toEqual([expect.stringMatching(/^resources\/src@.*$/)]); |
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.
I wonder how did this test work before? This PR does not seem to affect this behavior, does it?
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.
I'm not sure what exactly, but some change in this PR made filteredStack
contain something when testInfo.attach()
is called. That leads tracing to include the source code as a resource. Let me refactor this assertion to make that more clear.
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.
there you go: d277551
@@ -393,3 +391,48 @@ test('should show custom fixture titles in actions tree', async ({ runUITest }) | |||
/After Hooks[\d.]+m?s/, | |||
]); | |||
}); | |||
|
|||
test('attachments tab shows all but top-level .push attachments', async ({ runUITest }) => { |
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.
Sounds fine for now. I see that's already done in the testInfo.ts
?
We can follow up by adding a timestamp to attachments and emitting a separate "testend" event in the trace with all the leftover attachments. At that point we can possibly remove "attach foo" steps as well. Up for discussion.
@@ -50,6 +50,16 @@ Start time of this particular test step. | |||
|
|||
List of steps inside this step. | |||
|
|||
## property: TestStep.attachments |
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.
Seeing that every reporter implementation immediately turns this into indices, perhaps we should revisit the API and make this an array of numbers? This does not block the PR, but please put it as an explicit topic for the API review.
@@ -512,8 +516,11 @@ class TeleTestStep implements reporterTypes.TestStep { | |||
parent: reporterTypes.TestStep | undefined; | |||
duration: number = -1; | |||
steps: reporterTypes.TestStep[] = []; | |||
attachments: reporterTypes.TestStep['attachments'] = []; |
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.
Let's make this a getter and compute lazily upon access? There is a memory pressure problem when merging a lot of large reports, and this class takes the most memory because there are a lot of steps.
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.
I made it a getter in 365b30f. We can look into refactoring the rest of this as well, so that TeleTestStep
only keeps _startPayload
and _endPayload
references.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Test results for "tests 1"7 flaky37498 passed, 650 skipped Merge workflow run. |
Closes #32748.
Adds a
TestStep.attachments
array to the Reporter API that shows all attachments created by the step. Removes the artificialattach "foo"
step for all calls exceptTestInfo.attach()
.This also means some changes to the HTML report attachment links introduced in #33267:
attach "foo"
step to their parent step