堅牢で安定したテスト 制限のないテストシナリオ テストの完全な分離と高速化 テスト作成とデバッグのための強力なツール WebフロントエンドのE2Eテストを自動化するた めのツール Playwright enables reliable end-to-end testing for modern web apps. GET STARTED Star 65k+ Playwright
https://playwright.dev/docs/intro#installing-playwright $ node -v v20.12.2 [1] $ npm init playwright@latest Need to install the following packages: [email protected] Ok to proceed? (y) y Getting started with writing end-to-end tests with Playwright: Initializing project in '.' ✔ Do you want to use TypeScript or JavaScript? · TypeScript ✔ Where to put your end-to-end tests? · tests ✔ Add a GitHub Actions workflow? (y/N) · false ✔ Install Playwright browsers (can be done manually via 'npx playwright install')? (Y/n) · true ✔ Install Playwright operating system dependencies (requires sudo / root - can be done manually via 'sudo npx playwright in [*1] 2024年4月時点での最新バージョンは v1.43.1
playwright show-report Serving HTML report at http://localhost:9323. Press Ctrl+C to quit. 4/18/2024, 2:55:30 PM Total time: 3.5s example.spec.ts example.spec.ts:3 example.spec.ts:10 example.spec.ts:3 example.spec.ts:10 example.spec.ts:3 example.spec.ts:10 All 6 Passed 6 Failed 0 Flaky 0 Skipped 0 253ms has title chromium 390ms get started link chromium 672ms has title firefox 735ms get started link firefox 469ms has title webkit 730ms get started link webkit
just a demo of TodoMVC for testing, not the real TodoMVC app. Double-click to edit a todo Double-click to edit a todo Created by Created by Remo H. Jansen Remo H. Jansen Part of Part of TodoMVC TodoMVC todos What needs to be done? test.beforeEach(async ({ page }) => { await page.goto('https://demo.playwright.dev/todomvc'); }); const TODO_ITEMS = [ 'buy some cheese', 'feed the cat', 'book a doctors appointment' ]; test('should allow me to add todo items', async ({ page }) => { // create a new todo locator const newTodo = page.getByPlaceholder('What needs to be done?'); // Create 1st todo. await newTodo.fill(TODO_ITEMS[0]); await newTodo.press('Enter'); // Make sure the list only has one todo item. await expect(page.getByTestId('todo-title')).toHaveText([ TODO_ITEMS[0] ]); // Create 2nd todo. await newTodo.fill(TODO_ITEMS[1]); await newTodo.press('Enter'); // Make sure the list now has two todo items. await expect(page.getByTestId('todo-title')).toHaveText([ TODO_ITEMS[0],