Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: add more baseURL tests for edge-cases (#7586)

Max Schmitt053d39cb19d7
diff --git a/tests/browsercontext-base-url.spec.ts b/tests/browsercontext-base-url.spec.ts
index db2fdc6fbc..cb283c3c3d 100644
--- a/tests/browsercontext-base-url.spec.ts
+++ b/tests/browsercontext-base-url.spec.ts
@@ -34,6 +34,17 @@ it('should construct a new URL when a baseURL in browser.newPage is passed to pa
await page.close();
});
+it('should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto', async function({browserType, server, createUserDataDir, browserOptions}) {
+ const userDataDir = await createUserDataDir();
+ const context = await browserType.launchPersistentContext(userDataDir, {
+ ...browserOptions,
+ baseURL: server.PREFIX,
+ });
+ const page = await context.newPage();
+ expect((await page.goto('/empty.html')).url()).toBe(server.EMPTY_PAGE);
+ await context.close();
+});
+
it('should construct the URLs correctly when a baseURL without a trailing slash in browser.newPage is passed to page.goto', async function({browser, server}) {
const page = await browser.newPage({
baseURL: server.PREFIX + '/url-construction',
@@ -91,3 +102,12 @@ it('should be able to match a URL relative to its given URL with urlMatcher', as
expect((await response.body()).toString()).toBe('base-url-matched-route');
await page.close();
});
+
+it('should not construct a new URL with baseURL when a glob was used', async function({browser, server}) {
+ const page = await browser.newPage({
+ baseURL: server.PREFIX + '/foobar/',
+ });
+ await page.goto('./kek/index.html');
+ await page.waitForURL('**/foobar/kek/index.html');
+ await page.close();
+});