All skills
fugazi avatar

/playwright-e2e-testing

@96feaff

Author and maintain versioned Playwright (@playwright/test) TypeScript UI specs for browser user flows. Use when asked to create, run, debug, or refactor E2E tests, form/navigation/auth flows, responsive checks, UI mocking, fixtures, Page Objects, or visual comparisons. Use api-testing for standalone REST/GraphQL contracts and playwright-cli for live browser sessions. Keywords: E2E spec, Playwright test, POM, fixtures, UI regression.

Use this Skill: https://skilld.dev/gh/fugazi/test-automation-skills-agents/playwright-e2e-testing

This session only. Nothing lands on disk.

referencesdebugging-errors-network.md

≈646 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Debugging: Console Errors & Network

Part of the playwright-e2e-testing skill. See SKILL.md for full context.

Related: this file was split from the original debugging.md. See the other debugging-*.md files in this folder for related sections.

Console & Page Errors

Capture Console Messages

test("monitor console", async ({ page }) => {
  const consoleLogs: string[] = [];

  page.on("console", (msg) => {
    consoleLogs.push(`[${msg.type()}] ${msg.text()}`);
  });

  page.on("pageerror", (error) => {
    consoleLogs.push(`[ERROR] ${error.message}`);
  });

  await page.goto("/");

  // Check for errors
  const errors = consoleLogs.filter((log) => log.includes("[error]"));
  expect(errors).toHaveLength(0);
});

Fixture for Auto-Capture

// fixtures/debug.fixture.ts
import { test as base, TestInfo } from "@playwright/test";

export const test = base.extend({
  page: async ({ page }, use, testInfo) => {
    const logs: string[] = [];

    page.on("console", (msg) => logs.push(`[${msg.type()}] ${msg.text()}`));
    page.on("pageerror", (err) => logs.push(`[ERROR] ${err.message}`));

    await use(page);

    // Attach logs on failure
    if (testInfo.status !== testInfo.expectedStatus && logs.length) {
      await testInfo.attach("console-logs.txt", {
        body: logs.join("\n"),
        contentType: "text/plain",
      });
    }
  },
});

Network Debugging

Monitor Requests

test("debug network", async ({ page }) => {
  const requests: string[] = [];
  const failures: string[] = [];

  page.on("request", (req) => {
    requests.push(`${req.method()} ${req.url()}`);
  });

  page.on("requestfailed", (req) => {
    failures.push(`${req.method()} ${req.url()} - ${req.failure()?.errorText}`);
  });

  page.on("response", (res) => {
    if (!res.ok()) {
      console.log(`HTTP ${res.status()} ${res.url()}`);
    }
  });

  await page.goto("/");

  console.log("Total requests:", requests.length);
  console.log("Failed requests:", failures);
});

Wait for Specific Request

test("debug API call", async ({ page }) => {
  // Set up listener before action
  const responsePromise = page.waitForResponse(
    (res) => res.url().includes("/api/data") && res.status() === 200,
  );

  await page.goto("/dashboard");

  const response = await responsePromise;

  // Inspect response
  console.log("Status:", response.status());
  console.log("Headers:", response.headers());
  console.log("Body:", await response.json());
});

Source: SKILL.md on GitHub

1 warning16d4 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    No security issues detected. The skill provides standard and safe instructions for authoring Playwright E2E tests, following best practices for locator usage and Page Object Model implementation.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    3/5 files flagged

Signed by skilld at 96feaff. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 2 months ago

README badge

README badge for fugazi/test-automation-skills-agents/playwright-e2e-testing