I'm having an issue setting the baseURL for my project. By all tutorials that I watched and tried to replicate, setting the baseURL in the playwright.config.ts should do the trick. However, when I try to use inside the test or a class, the URL comes empty.
Basically what I did:
playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
baseURL: 'https://example.com',
};
export default config;
mytest.spec.ts
test('Example test', async ({ page, config }) => {
await page.goto('/');
}
Does the test need any type of import for it to work? Isn't playwright.config.ts global?
I believe that your
playwright.config.tsshould be:Now anywhere in the test if you use non-absolute URL, it will assume https://example.com as the base of the URL.