Skip to content

Commit

Permalink
Add a warning when none of the projects are using Replay Chromium (#502)
Browse files Browse the repository at this point in the history
* Add a warning when none of the projects are using Replay Chromium

* add changeset
  • Loading branch information
Andarist authored May 31, 2024
1 parent 41af2d6 commit 9122af4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-suits-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@replayio/playwright": patch
---

Added a warning when the reporter gets used without the Replay browser
24 changes: 11 additions & 13 deletions packages/playwright/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,9 @@ class ReplayPlaywrightReporter implements Reporter {
string,
{ steps: FixtureStep[]; stacks: Record<string, StackFrame[]>; filenames: Set<string> }
> = {};
private _foundReplayBrowser = false;

constructor(config: ReplayPlaywrightConfig) {
const browserPath = getPlaywrightBrowserPath("chromium");

if (!browserPath) {
throw new Error(`replay-chromium is not supported on this platform`);
}

if (process.platform !== "win32" && !existsSync(browserPath)) {
throw new Error(
`replay-chromium is not available at ${browserPath}. Please run \`npx replayio install\`.`
);
}

if (!config || typeof config !== "object") {
throw new Error(
`Expected an object for @replayio/playwright/reporter configuration but received: ${config}`
Expand Down Expand Up @@ -173,7 +162,11 @@ class ReplayPlaywrightReporter implements Reporter {
};
}

onBegin({ version }: FullConfig) {
onBegin({ version, projects }: FullConfig) {
const replayBrowserPath = getPlaywrightBrowserPath("chromium");
this._foundReplayBrowser = !!projects.find(
p => p.use.launchOptions?.executablePath === replayBrowserPath
);
this.reporter.setTestRunnerVersion(version);
this.reporter.onTestSuiteBegin();
}
Expand Down Expand Up @@ -319,6 +312,11 @@ class ReplayPlaywrightReporter implements Reporter {

async onEnd() {
await this.reporter.onEnd();
if (!this._foundReplayBrowser) {
console.warn(
"[replay.io]: None of the configured projects ran using Replay Chromium. Please recheck your Playwright config and make sure that Replay Chromium is installed. You can install it using `npx replayio install`"
);
}
}

parseArguments(apiName: string, params: any) {
Expand Down

0 comments on commit 9122af4

Please sign in to comment.