-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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(tracing) Adding groups to trace via pw-api #33081
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@microsoft-github-policy-service agree |
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 PR!
I agree with your choice of ignoring group()
/groupEnd()
calls when not tracing or when groupEnd()
is unbalanced. That seems like the easiest one for the user.
We would need tests that should go into trace-viewer.spec.ts.
Take a look at testd like should have correct stack trace
, should show action source
and should open simple trace viewer
. In the last one, I'd click on a group to expand/collapse it and check the actions list.
I think this should automatically work with the test runner if you follow my other comments. Adding a test similar to this one will ensure that.
Overall, this looks very promising, thank you!
@@ -51,6 +52,18 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap | |||
await this._startCollectingStacks(traceName); | |||
} | |||
|
|||
async group(name: string, options: { location?: { file: string, line?: number, column?: number } } = {}) { | |||
if (!options.location) { | |||
const filteredStack = filteredStackTrace(captureRawStack()); |
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.
Instead of handling the stack manually, we should fall back to the default machinery. That probably means calling _wrapApiCall()
and introducing an extra parameter to pass a custom location to it, instead of taking the stack trace. This way you'll get source collection and other goodies for free.
You would also need to opt-out of this._isInternalType
check inside to make this particular tracing.group()
call public. I think that making isInternal
argument be boolean | undefined
will allow to differentiate explicit false
to opt-into public call from default undefined
which aligns with this._isInternalType
.
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.
Actually i do not really understand what you are talking about here, but can it be that this is all irrelevant when using metadata.location
as i described in my comment before?
This comment has been minimized.
This comment has been minimized.
@dgozman Update: Test written |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PS: It seems to me that you also have some flaky tests? Is it possible to give the users that do PRs the right, to re-run failed actions? |
@pavelfeldman @dgozman We would really love to see that in next Playwright Release, so that we could implement it in Robot Framework Browser as well. Thank you. |
@Snooz82 Sorry, I didn't get to this PR today, but I will tomorrow.
|
This comment has been minimized.
This comment has been minimized.
@dgozman Thanks for the feedback.
You may review again. There is one limitation though. Thanks for reviewing! |
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.
Hi @dgozman, I am sorry that i might be annoying. Thank you. |
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
Co-authored-by: Dmitry Gozman <dgozman@gmail.com> Signed-off-by: René <41592183+Snooz82@users.noreply.github.com>
Co-authored-by: Dmitry Gozman <dgozman@gmail.com> Signed-off-by: René <41592183+Snooz82@users.noreply.github.com>
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: René <snooz@posteo.de>
This comment has been minimized.
This comment has been minimized.
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 your patience, this required a bit more work than most of the PRs.
-
I've played with the change, and integrated it with the test runner. Please incorporate the following diff: https://gist.github.com/dgozman/2ccb5bbb012f0aa9716b9aa2174ff719.
-
Please also add a test for test runner integration, similar to this one. I'd like it to check the following snippet:
await page.setContent(`<body><div><span><h1>text</h1></span></div></body>`); await test.step('custom step', async () => { await page.context().tracing.group('outer group'); await page.context().tracing.group('inner group'); await page.locator('body').click(); await page.context().tracing.groupEnd(); await page.locator('div').click(); await page.context().tracing.groupEnd(); await page.locator('span').click(); }); await page.locator('h1').click();
-
See also other comments.
Thank you for this PR, I think it will turn out as a nice feature.
Signed-off-by: René <snooz@posteo.de>
Signed-off-by: René <snooz@posteo.de>
All requested changes are done. Thanks |
Test results for "tests 1"36447 passed, 639 skipped Merge workflow run. |
Hey folks! Chiming in a bit late here. I'm working on a change in a related area so this is interesting to see. I'm wondering if it'd be better to call this "steps" instead of "groups"? As you're saying, this is pretty similar to steps in how it works and what it does. So we could reuse the term and make it less confusing to users. We could also make the API similar and use @Snooz82 What are your thoughts on this? Did you consider calling it "steps"? What term do you prefer, and why? |
Hi @Skn0tt just actually i think now that grouping is a more generic word than step. and i would now prefer:
but to be honest, i do not really care. 😉 i would just hope that this feature could be finalized sooner than later. 🙂 |
Sounds good! Seeing the discussion in #33047, it looks like the naming has already been considered well :) Taking back my point then. |
@dgozman may i ask if i can do anything to accelerate this PR? best regards |
Dmitry is currently out of office, so expect to wait a couple more days. |
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 looks mostly good. I am going to merge this and follow up with minor improvements.
🥳 |
This PR implements #33047 .
It shall be possible to add groups to trace logs so that also users that do not use Playwright-Test, like Playwright Python, Robot Framework, Cucumber etc., can also group their traces.
Similar to test.step visually.