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(trace viewer): Adds _debugName BrowserContextOption to let users define a name for their contexts #5205
Conversation
… define a name for their contexts. This change is adding a new property on the BrowserContextOptions class called `_debugName`. This property allows defining a user-friendly name for the browser context, and currently it is being used in one place, the Trace Viewer. When user provides the new value in the following way: ```typescript const { chromium } = require('playwright'); (async () => { const browser = await chromium.launch(); const context = await browser.newContext({ _traceDir: __dirname, _debugName: 'My custom testcase name' }); await context.close(); await browser.close(); })(); ``` The `_debugName` will be saved in the `*.trace` file for this browser context, on the `context-created` event, under the key `debugName`. Later, when such a trace is displayed using Trace Viewer, the `debugName` will be displayed in the dropdown in the top right part of the app instead of the actual trace filename. Fixes microsoft#5157.
Hey, two things to clarify here:
it('should record trace', (test, { browserName, platform }) => {
test.fixme();
}, async ({browser, testInfo, server}) => {
...
}); This looks like those tests are disabled on purpose at the moment. I added a new test checking the |
Oh I also didn't add the docs yet, again not sure if those get added once the functionality is ready for deployment, or if it should be added in this PR. |
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 great!
@@ -111,3 +113,19 @@ it('should record trace with POST', (test, { browserName, platform }) => { | |||
expect(fs.existsSync(path.join(traceDir, 'resources', resourceEvent.requestSha1))).toBe(true); | |||
expect(fs.existsSync(path.join(traceDir, 'resources', resourceEvent.responseSha1))).toBe(true); | |||
}); | |||
|
|||
it('should record trace with a debugName', (test, { browserName, platform }) => { | |||
test.fixme(); |
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.
Tracing tests are flaky on the bots, I still need to figure out why and reenable them.
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.
What do you mean by bots?
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 mean our GitHub actions.
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.
Ah ok thanks
@@ -373,6 +373,7 @@ BrowserType: | |||
- no-preference | |||
acceptDownloads: boolean? | |||
_traceDir: string? | |||
_debugName: string? |
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.
Underscore is good. We'll make it public once we are sure about the api. No need for docs yet.
This change is adding a new property on the BrowserContextOptions class called
_debugName
. This property allows defining a user-friendly name for the browser context, and currently it is being used in one place, the Trace Viewer. When user provides the new value in the following way:The
_debugName
will be saved in the*.trace
file for this browser context, on thecontext-created
event, under the keydebugName
.Later, when such a trace is displayed using Trace Viewer, the
debugName
will be displayed in the dropdown in the top right part of the app instead of the actual trace filename.Fixes #5157.