From eac857a0106d0f0a879bbfddee84e11cc1347af5 Mon Sep 17 00:00:00 2001 From: Steve Kinney Date: Tue, 8 Oct 2024 17:04:08 -0600 Subject: [PATCH] Demonstrate Playwright --- examples/accident-counter/tests/counter.spec.js | 12 +++++++++++- examples/task-list/tests/task-list.spec.js | 5 ++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/accident-counter/tests/counter.spec.js b/examples/accident-counter/tests/counter.spec.js index e924d05..cf025bf 100644 --- a/examples/accident-counter/tests/counter.spec.js +++ b/examples/accident-counter/tests/counter.spec.js @@ -1,2 +1,12 @@ 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(); +}); diff --git a/examples/task-list/tests/task-list.spec.js b/examples/task-list/tests/task-list.spec.js index f43a1fb..60c1b7c 100644 --- a/examples/task-list/tests/task-list.spec.js +++ b/examples/task-list/tests/task-list.spec.js @@ -1,8 +1,7 @@ import { test, expect } from '@playwright/test'; -/** @type {import('../start-server').DevelopmentServer} */ test.beforeEach(async ({ page }) => { - await page.goto('http://localhost:5173'); + await page.goto('http://localhost:5174'); }); 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 submit.click(); - const heading = await page.getByRole('heading', { name: 'Learn Playwright' }); + const heading = page.getByRole('heading', { name: 'Learn Playwright' }); await expect(heading).toBeVisible(); });