Skip to content

Commit

Permalink
test: add more baseURL tests for edge-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Jul 13, 2021
1 parent 767e22c commit c59b80b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/browsercontext-base-url.spec.ts
Expand Up @@ -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',
Expand Down Expand Up @@ -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();
});

0 comments on commit c59b80b

Please sign in to comment.