playwright-testing
Skill54 starsChanged 3 months agoMITView on GitHub
Generer og kjør Playwright E2E-tester for webapplikasjoner med page objects, auth fixtures og tilgjengelighetstester
- Reads credentials
- Installs packages
8 other projects use a version of this.
Adopted by
Most recently taken up by
- ZeroTokenClaw/agents-skillstheir own version, first seen Sep 21, 2026
- n-n-code/n-n-code-skillstheir own version, first seen Sep 5, 2026
- alinaqi/maggytheir own version, first seen Jun 12, 2026
- jorgeasaurus/agent-skillstheir own version, first seen May 11, 2026
- chongdashu/vibejam-starter-packtheir own version, first seen Apr 15, 2026
- chongdashu/threejs-tactics-gametheir own version, first seen Mar 6, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- alinaqi/maggy★ 707same name
- chongdashu/vibejam-starter-pack★ 149same name
- chongdashu/threejs-tactics-game★ 32same name
- jorgeasaurus/agent-skills★ 13same name
- n-n-code/n-n-code-skills★ 4same name
- dtinth/agent-skills★ 2same name
- medy-gribkov/arcana★ 1same name
- ZeroTokenClaw/agents-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- ai-news-researchSkill
- aksel-builderSkill
- aksel-spacingSkill
- api-designSkill
- conventional-commitSkill
- deliberate-ai-useSkill
- flyway-migrationSkill
- jackson-3-migrationSkill
- java-to-kotlinSkill
- kafkaSkill
- klarsprakSkill
- kotlin-app-configSkill
- ktor-scaffoldSkill
- naisSkill
- nav-architecture-reviewSkill
- nav-authSkill
- nav-deep-interviewSkill
- nav-dekoratorenSkill
- nav-planSkill
- nav-troubleshootSkill
- observability-debuggingSkill
- observability-setupSkill
- postgresql-reviewSkill
- readme-reviewSkill
- rust-developmentSkill
- security-owaspSkill
- security-reviewSkill
- spring-boot-scaffoldSkill
- terse-modeSkill
- threat-modelSkill
- tokenx-authSkill
- web-design-reviewerSkill
- workstation-securitySkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Create page objects for your app's pages
- Distinctive: line 20
Write tests: navigation, forms, responsive, accessibility
- Distinctive: line 21
Add CI workflow in GitHub Actions
- Very specific: line 280
Parallel tests: Keep tests independent so fullyParallel: true works
“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Playwright E2E Testing Skill
Generate Playwright tests for Nav web applications. Covers page object pattern, authentication fixtures, accessibility testing, and CI configuration.
Getting Started
- Install Playwright and configure
playwright.config.ts - Create page objects for your app's pages
- Set up auth fixtures for Azure AD / MockOAuth2Server
- Write tests: navigation, forms, responsive, accessibility
- Add CI workflow in GitHub Actions
1. Project Setup
# Install Playwright
pnpm add -D @playwright/test
pnpm exec playwright install --with-deps chromium
# Create configuration
pnpm exec playwright initplaywright.config.ts
import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
testDir: "./e2e",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [["html", { open: "never" }]],
use: {
baseURL: process.env.BASE_URL ?? "http://localhost:3000",
trace: "on-first-retry",
screenshot: "only-on-failure",
},
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
{ name: "mobile", use: { ...devices["Pixel 7"] } },
],
webServer: {
command: "pnpm dev",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
},
});2. Page Object Pattern
// e2e/pages/oversikt.page.ts
import { type Locator, type Page, expect } from "@playwright/test";
export class OversiktPage {
readonly heading: Locator;
readonly searchField: Locator;
readonly table: Locator;
constructor(private readonly page: Page) {
this.heading = page.getByRole("heading", { name: /oversikt/i });
this.searchField = page.getByRole("searchbox", { name: /søk/i });
this.table = page.getByRole("table");
}
async goto() {
await this.page.goto("/oversikt");
await expect(this.heading).toBeVisible();
}
async search(query: string) {
await this.searchField.fill(query);
await this.searchField.press("Enter");
}
async expectRowCount(count: number) {
const rows = this.table.getByRole("row");
// Minus header row
await expect(rows).toHaveCount(count + 1);
}
}3. Auth Fixture (Azure AD / MockOAuth2Server)
// e2e/fixtures/auth.ts
import { test as base } from "@playwright/test";
type AuthFixtures = {
authenticatedPage: ReturnType<typeof base["page"]>;
};
export const test = base.extend<AuthFixtures>({
authenticatedPage: async ({ page, context }, use) => {
// Set auth cookie for test environment
await context.addCookies([
{
name: "selvbetjening-idtoken",
value: process.env.TEST_TOKEN ?? "test-token",
domain: "localhost",
path: "/",
},
]);
await use(page);
},
});
export { expect } from "@playwright/test";4. Test Examples
Page Navigation
// e2e/tests/navigation.spec.ts
import { test, expect } from "@playwright/test";
test.describe("Navigation", () => {
test("should navigate to oversikt page", async ({ page }) => {
await page.goto("/");
await page.getByRole("link", { name: /oversikt/i }).click();
await expect(page).toHaveURL(/\/oversikt/);
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
});
test("should show 404 for unknown routes", async ({ page }) => {
const response = await page.goto("/ukjent-side");
expect(response?.status()).toBe(404);
});
});Form
// e2e/tests/form.spec.ts
import { test, expect } from "@playwright/test";
test.describe("Søknadsskjema", () => {
test("should submit form successfully", async ({ page }) => {
await page.goto("/soknad");
await page.getByLabel("Navn").fill("Ola Nordmann");
await page.getByLabel("E-post").fill("ola@nav.no");
await page.getByRole("combobox", { name: /tema/i }).selectOption("dagpenger");
await page.getByRole("button", { name: /send inn/i }).click();
await expect(page.getByRole("alert")).toContainText("Sendt");
});
test("should show validation errors", async ({ page }) => {
await page.goto("/soknad");
await page.getByRole("button", { name: /send inn/i }).click();
await expect(page.getByText("Navn er påkrevd")).toBeVisible();
await expect(page.getByText("E-post er påkrevd")).toBeVisible();
});
});Responsive Design
// e2e/tests/responsive.spec.ts
import { test, expect, devices } from "@playwright/test";
test.describe("Responsive", () => {
test("should show mobile menu on small screens", async ({ page }) => {
await page.setViewportSize({ width: 375, height: 812 });
await page.goto("/");
await expect(page.getByRole("button", { name: /meny/i })).toBeVisible();
await expect(page.getByRole("navigation")).not.toBeVisible();
await page.getByRole("button", { name: /meny/i }).click();
await expect(page.getByRole("navigation")).toBeVisible();
});
test("should show full navigation on desktop", async ({ page }) => {
await page.setViewportSize({ width: 1280, height: 800 });
await page.goto("/");
await expect(page.getByRole("navigation")).toBeVisible();
});
});5. Accessibility Testing med axe
// e2e/tests/accessibility.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test.describe("Accessibility", () => {
const pages = ["/", "/oversikt", "/usage"];
for (const path of pages) {
test(`${path} should have no a11y violations`, async ({ page }) => {
await page.goto(path);
const results = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa", "wcag21aa"])
.analyze();
expect(results.violations).toEqual([]);
});
}
});6. CI Configuration (GitHub Actions)
# .github/workflows/e2e.yml
e2e:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright install --with-deps chromium
- run: pnpm exec playwright test
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: playwright-report/Locator Strategies
Prioritized order for finding elements:
// 1. ✅ Role-based (best)
page.getByRole("button", { name: /send inn/i });
page.getByRole("heading", { level: 1 });
page.getByRole("link", { name: /oversikt/i });
// 2. ✅ Label-based (for form elements)
page.getByLabel("Fødselsnummer");
page.getByPlaceholder("Søk...");
// 3. ✅ Text-based (for static content)
page.getByText("Ingen resultater");
// 4. ⚠️ Test ID (only when role/label doesn't work)
page.getByTestId("metrics-chart");
// 5. ❌ CSS selectors (avoid)
page.locator(".my-class");
page.locator("#my-id");Tips
- Implicit waiting: Playwright waits automatically for elements — avoid
page.waitForTimeout() - Isolate tests: Each test should be able to run independently
- Use
test.describeto group related tests - Parallel tests: Keep tests independent so
fullyParallel: trueworks - Screenshots: Automatic on failure — check the
test-results/directory
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

