Skip to content

Commit

Permalink
Writing Playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasphung committed Jul 17, 2024
1 parent c5dc9ca commit c255af5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 438 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Tests passed\" && exit 0"
"test": "echo \"Tests passed\" && exit 0",
"e2e-test": "npm start && npx playwright test",
"e2e-create": "npm start && npx playwright codegen # How do I start my server to create Playwright tests locally using codegen?"
},
"author": "",
"license": "ISC",
Expand Down
17 changes: 17 additions & 0 deletions tests/e2e/connect4_playwright/connect4.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { test, expect } from '@playwright/test';

test('Play game of Connect 4', async ({ page }) => {
await page.goto('http://localhost:3000/');
await page.getByRole('button', { name: 'New Game' }).click();
await page.locator('[id="\\30 "]').click();
await page.locator('[id="\\30 "]').click();
await page.locator('[id="\\31 "]').click();
await page.locator('[id="\\31 "]').click();
await page.locator('[id="\\32 "]').click();
await page.locator('[id="\\32 "]').click();
page.once('dialog', dialog => {
console.log(`Dialog message: ${dialog.message()}`);
dialog.dismiss().catch(() => {});
});
await page.locator('[id="\\33 "]').click();
});
Loading

0 comments on commit c255af5

Please sign in to comment.