Skip to content

Commit 13bcb79

Browse files
committed
add tests for withBrowser scope cleanup
1 parent b98027c commit 13bcb79

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/experimental/environment.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,32 @@ layer(layerPlaywrightEnvironment(chromium))("PlaywrightEnvironment", (it) => {
9191
}),
9292
),
9393
);
94+
95+
it.effect("withBrowser scope cleanup", () =>
96+
Effect.gen(function* () {
97+
let capturedBrowser: typeof PlaywrightBrowser.Service | undefined;
98+
99+
yield* withBrowser(
100+
Effect.gen(function* () {
101+
const browser = yield* PlaywrightBrowser;
102+
capturedBrowser = browser;
103+
104+
yield* browser.newPage({ baseURL: "about:blank" });
105+
106+
yield* accessFirst;
107+
yield* accessSecond;
108+
}),
109+
);
110+
111+
assert(capturedBrowser, "Expected browser");
112+
const contexts = yield* capturedBrowser.contexts;
113+
assert(contexts.length === 0, "Expected no contexts");
114+
115+
// actually not connected anymore
116+
assert(
117+
(yield* capturedBrowser.isConnected) === false,
118+
"Expected not connected",
119+
);
120+
}),
121+
);
94122
});

0 commit comments

Comments
 (0)