Luca Del Puppo
Luca Del Puppo
Love sport: running, hiking
Love animals
reliable end-to-end testing for modern web apps
NPM
VSCode Extension
import { expect, test } from "@playwright/test";
test("has title", async ({ page }) => {
await page.goto("https://delpuppo.net/");
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/luca del puppo | developer portfolio/i);
});
strict by default
Locator
Selector
page.getByText()
page.getByLabel()
page.getByPlaceholder()
page.getByAltText()
page.getTitle()
page.getByTestId()
> npx playwright show-report
> npx playwright test --trace on
test("test", async ({
page,
isMobile
}) => {
...
});
import { test, expect } from '@playwright/test';
// Run tests in this file with portrait-like viewport.
test.use({
viewport: { width: 600, height: 900 },
});
test('my portrait test', async ({ page }) => {
// ...
});
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
> npm init playwright@latest -- --ct
import { expect, test } from '@playwright/experimental-ct-react';
import FilterTag from './index';
test.describe('FilterTag', () => {
test('should render', async ({ page, mount }) => {
await mount(<FilterTag name="All" active={true} />);
await expect(page.locator('text=All')).toBeVisible();
});
});
React
Vue
Svelte
SolidJS
Code
@puppo92
Luca Del Puppo
Puppo_92
@puppo