Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: how to use with Playwright #2489

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions docs/guide/frameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,39 @@ describe('Testing the application', () => {
});
});
```

## Playwright

Integration with [Playwright](https://playwright.dev/) is also easy:

```ts
import { faker } from '@faker-js/faker/locale/en';
import { expect, test } from '@playwright/test';

test.describe('Testing the application', () => {
test('should create an account with username and password', async ({
page,
}) => {
const username = faker.internet.userName();
const password = faker.internet.password();
const email = faker.internet.exampleEmail();

// Visit the webpage and create an account.
await page.goto('https://www.example.com/register');
await page.getByLabel('email').fill(email);
await page.getByLabel('username').fill(username);
await page.getByLabel('password', { exact: true }).fill(password);
await page.getByLabel('confirm password').fill(password);
await page.getByRole('button', { name: 'Register' }).click();

// Now, we try to login with these credentials.
await page.goto('https://www.example.com/login');
await page.getByLabel('email').fill(email);
await page.getByLabel('password').fill(password);
await page.getByRole('button', { name: 'Login' }).click();

// We should have logged in successfully to the dashboard page.
await expect(page).toHaveURL(/.*dashboard/);
xDivisionByZerox marked this conversation as resolved.
Show resolved Hide resolved
});
});
```