Demonstrate Playwright

This commit is contained in:
Steve Kinney
2024-10-08 17:04:08 -06:00
parent 9ac6b6e1ef
commit eac857a010
2 changed files with 13 additions and 4 deletions

View File

@@ -1,2 +1,12 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { createServer } from 'vite';
test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:5173');
});
test('it has a counter', async ({ page }) => {
const count = page.getByTestId('counter-count');
const incrementButton = page.getByRole('button', { name: /increment/i });
await incrementButton.click();
});

View File

@@ -1,8 +1,7 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
/** @type {import('../start-server').DevelopmentServer} */
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:5173'); await page.goto('http://localhost:5174');
}); });
test('it should load the page', async ({ page }) => { test('it should load the page', async ({ page }) => {
@@ -16,7 +15,7 @@ test('it should add a task', async ({ page }) => {
await input.fill('Learn Playwright'); await input.fill('Learn Playwright');
await submit.click(); await submit.click();
const heading = await page.getByRole('heading', { name: 'Learn Playwright' }); const heading = page.getByRole('heading', { name: 'Learn Playwright' });
await expect(heading).toBeVisible(); await expect(heading).toBeVisible();
}); });