-
Notifications
You must be signed in to change notification settings - Fork 8
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
Improve the warning about Replay-less executions #585
Conversation
🦋 Changeset detectedLatest commit: 0e55651 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -164,14 +167,24 @@ class ReplayPlaywrightReporter implements Reporter { | |||
|
|||
onBegin({ version, projects }: FullConfig) { | |||
const replayBrowserPath = getRuntimePath(); | |||
this._foundReplayBrowser = !!projects.find( |
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.
@bvaughn noticed that projects
contain all configured projects - not only those that are executed in the test run.
So now, I'm tracking which projects are configured with Replay and then which are actually executed. That allows us to create a precise warning at the end of the run
packages/playwright/src/reporter.ts
Outdated
: `${projectsWithoutReplay.join(", ")} project${ | ||
projectsWithoutReplay.length > 1 ? "s" : "" | ||
}`; | ||
|
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 this produces a meaningfully better warning message to be worth it. I think just saying "Your tests ran without Replay Chromium" would be sufficient.
What would this actually look like in practice? My experience is pretty limited here, but the way I've typically seen projects named were like "firefox" or "chrome" So in that case this would print a warning like:
chrome project ran without Replay Chromium. If this wasn't intentional, please recheck your configuration.
or
firefox, chrome projects ran without Replay Chromium. If this wasn't intentional, please recheck your configuration.
Both of those seem kind of awkward to me, particularly if the project has a 1:1 relationship with a browser. I guess in most cases it would be the root project so we'd just say "Your project ran without Replay Chromium" but in that case, I think that saying "Your tests ran without Replay Chromium" might still read a little better?
packages/playwright/src/reporter.ts
Outdated
const projectsWithoutReplay = Object.keys(this._projects).filter(projectName => { | ||
const { executed, usingReplay } = this._projects[projectName]; | ||
return executed && !usingReplay; | ||
}); |
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 this is the check we want here. Shouldn't we actually be checking to ensure that at least one project using Replay ran? (It's okay if others ran that weren't using it.) e.g.
const shouldWarn = !Object.keys(this._projects).find(projectName => {
const { executed, usingReplay } = this._projects[projectName];
return executed && usingReplay;
});
I don't think we'd want to show ourselves this warning in the case when we chose to run with both regular Chromium and Replay Chromium, would we? (Maybe you think we would? Maybe you're worried about a case where different projects have different sets of tests they run? But that still seems pretty intentional to me.)
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.
When I initially implemented this warning I specifically didn't want to warn when "mixed" projects would be executed... and I just forgot about this intention when working on this. I think you are right here. This also addresses the other concern that you raised
packages/playwright/src/reporter.ts
Outdated
if (!existsSync(getRuntimePath())) { | ||
mixpanelAPI.trackEvent("playwright.warning.reporter-used-without-replay-browser"); |
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 think... putting this warning here doesn't make sense, does it? I was planning to follow up on this in PRO-751 but...wouldn't we error much earlier on when we tried to run the first test but there was no browser to run it with?
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.
wouldn't we error much earlier on when we tried to run the first test but there was no browser to run it with?
Not quite. We can't check what projects are actually executed in the constructor. So we start tracking this information in onBegin
but we also can't check what projects are actually executed there... so we only gain that knowledge in onEnd
as at that time we know about all executed tests and related projects.
You are right that all related tests would just fail in such a scenario. It would be a Playwright-generated error though, smth like:
1) [replay-chromium] › test/example.spec.ts:3:5 › basic test ─────────────────────────────────────
Error: browserType.launch: Failed to launch chromium because executable doesn't exist at /Users/mateuszburzynskiprev/.replay/runtimes/Replay-Chromium.app/Contents/MacOS/Chromium
And when that gets logged we can't add a mixpanel event.
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.
Okay. I was thinking we could perhaps detect and warn earlier (in onTestBegin
) but maybe it's better to print the error at the end anyway.
That being said, this check doesn't look right because it's warning unconditionally (even if Replay project wasn't used)
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.
That being said, this check doesn't look right because it's warning unconditionally (even if Replay project wasn't used)
Hm, yee - you are right. It makes sense to only warn about this on runs when Replay was meant to be executed.
packages/playwright/src/reporter.ts
Outdated
} | ||
|
||
if (executedProjectWithReplay && !existsSync(getRuntimePath())) { | ||
mixpanelAPI.trackEvent("playwright.warning.reporter-used-without-replay-browser"); |
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 think this sounds too similar to "playwright.warning.reporter-used-without-replay-project", particularly since Playwright seems to use "project" and "browser" interchangeably
Maybe we could make this more explicit? Something like?
mixpanelAPI.trackEvent("playwright.warning.reporter-used-without-replay-browser"); | |
mixpanelAPI.trackEvent("playwright.warning.replay-browser-not-installed"); |
Also should this be a warning or an error? I guess warning is okay?
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.
Also should this be a warning or an error? I guess warning is okay?
It depends. If no projects with Replay were selected then this could be a warning - otherwise an error. I don't feel like complicating it this way right now. It wouldn't be thrown here anyway.
|
||
if (executedProjectWithReplay && !existsSync(getRuntimePath())) { | ||
mixpanelAPI.trackEvent("playwright.warning.reporter-used-without-replay-browser"); | ||
if (output.length) { |
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 length check is not meaningful with how the code is currently structured. This is essentially already in an "else" block.
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 became meaningful again with the recent change
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 became meaningful again with the recent change
So happy for you 🥺
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.
😂
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
packages/playwright/src/reporter.ts
Outdated
} | ||
|
||
if (!existsSync(getRuntimePath())) { | ||
mixpanelAPI.trackEvent("playwright.warning.replay-browser-not-installed"); |
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 think the only thing I would tweak about this maybe is to conditionally report this error (if executedProjectWithReplay
) so we don't get a bunch of false positives in Mixpanel?
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.
good idea, i pushed out this change
No description provided.