Sample for e2e/frontend testing (used for talks)
- Clone https://github.com/sspringer82/wdc-next
- Open project wdc-next
- Start backend
npm run backend
- Start frontend
npm run dev
- Open ui: http://localhost:3000
- Open project in visual studio code
We already initialized playwright via npm init playwright@latest
-
Run the tests with
npx playwright test --headed --trace on
-
Show results
npx playwright show-report
-
Show visual studio extension
-
Debug existing test
-
Record a new test
- Open page
- Click Pizza
- Click headline
- Back
- Add to car
- Open Cart
- CLick item in cart
- Buy
- Click thank you
-
Add some assertions (one failing)
await page.goto('http://localhost:3000/list');
await page.getByRole('link', { name: 'Pizza' }).click();
await page.getByRole('link', { name: 'zurück zur Übersicht' }).click();
await page.getByTestId('add-to-cart-1').click();
await page.getByLabel('add to shopping cart').click();
await expect(page.getByTestId('item-title-1')).toContainText("Pizza");
await page.getByRole('button', { name: 'kaufen' }).click();
await expect(page.getByRole('heading', { name: 'Danke!' })).toBeVisible();
```