Im currently using a global-setup.ts file to load a url via playwright.
await page.goto('https://test1.com/');
I am also doing extra code inside here and storing the state of my object (All works as expected)
My playwright.config.ts file references the globalsetup and this all works as expected.
In my Config file I also set baseUrl however, I am struggling on a way to get the baseUrl passed to my global-setup.ts file instead of hardcoding it.
Thanks!
Inside your global setup, you can access the baseURL
like that:
import { FullConfig } from '@playwright/test';
async function globalSetup(config: FullConfig) {
console.log(config.projects[0].use.baseURL);
}
export default globalSetup
See here: https://playwright.dev/docs/api/class-testconfig/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With