I am using two URLs for dev and stg environments. These two environments also have different URL for API calls. This is my .env file:
URL1=https://playwright-dev.com/
URL2=https://playwright-stg.com/
BASE_URL1=https://playwright-dev/api/
BASE_URL2=https://playwright-stg/api/
And this is an example of how I am using it in the tests:
test('example', async ({ page, request }) => {
await page.goto(process.env.URL1);
let response = await request.put(`${process.env.BASE_URL1}/import`, {
headers: {authorization: `Bearer ${token}`},
data: JSON.parse(Data)
});
});
However, I would like to be able to select the wanted URL via command line and delete .env file, something like that:
URL=https://playwright-dev.com/ BASE_URL=https://playwright-dev/api/ npx playwright test
How can I do that? Thank you!