Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 3840ea7

Browse files
committed
Lazily set up ElementAppPage subfixtures to avoid conflicting on network routing
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 4dc597b commit 3840ea7

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

playwright/pages/ElementAppPage.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,23 @@ import { Spotlight } from "./Spotlight";
2424
export class ElementAppPage {
2525
public constructor(public readonly page: Page) {}
2626

27-
public settings = new Settings(this.page);
28-
public client: Client = new Client(this.page);
29-
public timeline: Timeline = new Timeline(this.page);
27+
// We create these lazily on first access to avoid calling setup code which might cause conflicts,
28+
// e.g. the network routing code in the client subfixture.
29+
private _settings?: Settings;
30+
public get settings(): Settings {
31+
if (!this._settings) this._settings = new Settings(this.page);
32+
return this._settings;
33+
}
34+
private _client?: Client;
35+
public get client(): Client {
36+
if (!this._client) this._client = new Client(this.page);
37+
return this._client;
38+
}
39+
private _timeline?: Timeline;
40+
public get timeline(): Timeline {
41+
if (!this._timeline) this._timeline = new Timeline(this.page);
42+
return this._timeline;
43+
}
3044

3145
/**
3246
* Open the top left user menu, returning a Locator to the resulting context menu.

0 commit comments

Comments
 (0)