It is recommended to install Playwright's official Visual Studio Code extension for a better testing experience and an interactive GUI.
Create a .env
file in the root folder of the project for your user credentials and host URL. HOST
, USER
and PASSWORD
are the environment variables required to run shared functions.
Here's an example .env
file contents:
export HOST="https://localhost:4173"
export ACCOUNT_USERNAME="user"
export ACCOUNT_PASSWORD="user"
Importing shared functions from shared.ts
:
import { login, host } from './shared';
Usage of shared functions in tests:
test('Test', async ({ page }) => {
await login(page); // Login
await page.goto(`${host}/test/`); // Go to /test route
});
You can check Playwright documentation page for more details, guides and information.