diff --git a/.changeset/wicked-suits-cheat.md b/.changeset/wicked-suits-cheat.md new file mode 100644 index 00000000..145c2854 --- /dev/null +++ b/.changeset/wicked-suits-cheat.md @@ -0,0 +1,5 @@ +--- +"@replayio/playwright": patch +--- + +Added a warning when the reporter gets used without the Replay browser diff --git a/packages/playwright/src/reporter.ts b/packages/playwright/src/reporter.ts index 2f320349..10ec7f65 100644 --- a/packages/playwright/src/reporter.ts +++ b/packages/playwright/src/reporter.ts @@ -79,20 +79,9 @@ class ReplayPlaywrightReporter implements Reporter { string, { steps: FixtureStep[]; stacks: Record; filenames: Set } > = {}; + 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}` @@ -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(); } @@ -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) {