E2e failure analyzer

From posit-dev/positron · View interactive version

E2e failure analyzer is an AI agent skill from the GitHub repository posit-dev/positron. Analyze e2e test failures from a GitHub Actions run. Provide a run ID or URL to download reports, extract traces/screenshots/logs, identify root causes, and get suggested actions. Works with both posit-dev/positron and posit-dev/positron-builds repos.

How to use this skill

Skill file

E2E Failure Analyzer

Analyzes Playwright e2e test failures from a GitHub Actions run using JSON reports, trace files, screenshots, and test logs to identify root causes and suggest next actions.

When to Use

Prerequisites

Helper Scripts

Scripts live alongside this skill in scripts/. Use the base directory path shown above when the skill loads (the "Base directory for this skill: ..." line) as $SKILL_DIR. Scripts require Node.js and are cross-platform (Windows via Git Bash, macOS, Linux). Scripts that extract from zip files require unzip to be available in PATH (included in Git Bash on Windows).

Consolidated scripts (preferred -- fewer tool calls)

Standalone scripts (used by consolidated scripts internally, or for ad-hoc debugging)

Input

Run ID or URL from either repo:

Step 1: Gather Run Info (single script call)

The consolidated e2e-gather-run-info.js script handles everything: run metadata, failed jobs, blob report artifacts, non-e2e job log excerpts, and commit info.

node "$SKILL_DIR/scripts/e2e-gather-run-info.js" <RUN_URL>

Output JSON contains:

Read failedJobs[].steps before you touch any test evidence. A job keeps running past a failed step whenever the later steps carry their own if: conditions, so a job can fail to install R and still run the whole R suite against a half-provisioned runner -- and the Playwright report shows only that the tests failed. Each job's steps gives:

The script also prints a WARNING: <job> ran its tests after a failed setup step: ... line to stderr for each affected job, so the signal is visible without re-reading the JSON. The analysis rubric section "Check the job's own setup steps before blaming the product" has the decision rule -- including why you must NOT group such a failure with the same test failing on a platform whose setup was clean.

Use projects to determine what to process:

The two repos have different data access patterns:


Path A: posit-dev/positron (Sharded Blob Reports)

A1+A2: Download, Merge, and Process (single script call)

The e2e-process-project.js script handles everything in one call: downloads blob report artifacts, copies shards into a merged directory, runs npx playwright merge-reports, then extracts failures, scans blobs, extracts/parses traces, and extracts screenshots. Use --cleanup to remove intermediate download/merge artifacts automatically.

For each project from Step 1, run:

node "$SKILL_DIR/scripts/e2e-process-project.js" \
  --download --run-id <RUN_ID> --repo <REPO> --project <PROJECT> \
  --output-dir /tmp/e2e-analysis-<PROJECT> --cleanup

If there are multiple projects, run them sequentially (each call uses npx internally).

Fallback: If blob reports were already downloaded and merged (e.g., for debugging), you can skip --download and pass the directories directly:

node "$SKILL_DIR/scripts/e2e-process-project.js" \
  /tmp/blob-merged-<PROJECT> /tmp/report-<PROJECT>.json \
  --output-dir /tmp/e2e-analysis-<PROJECT>

Output JSON contains:

IMPORTANT: View screenshots using the screenshotPaths arrays with the Read tool. You MUST Read all screenshots in a single message with multiple parallel Read tool calls -- this results in only one approval prompt instead of one per screenshot. View all attempts and all frames per attempt; comparing across retries reveals whether a failure is consistent or intermittent, and comparing the trailing frames within an attempt often shows where the test went wrong before the visible error. Screenshots are the most revealing evidence for diagnosing failures. Default frame count per attempt is 3 (configurable via --screenshots N on e2e-process-project.js).

View the error-context page snapshot with the Read tool using errorContextPath paths. For any locator-not-found, "not visible", element-count, or text/attribute failure, Read it FIRST (not as a last resort): it captures the failure-state accessibility tree -- the only evidence that distinguishes a stale test selector from a real product regression, since a screenshot cannot. See the analysis rubric.

Reading the DOM-presence and console-digest sections. These two derived sections are appended to each attempt's trace.timeline (no extra file to open). They exist to separate a product open-path bug from an environment flake when a click/keypress "does nothing":

logExcerpt on each test is the attached logs sliced to that same window, with all severities kept plus a derived "went quiet before the deadline" report. An [info]-level success line inside the window frequently refutes an "external dependency broke" theory, and a log falling silent exactly when the UI should have appeared is positive evidence -- neither is visible to an error-keyword grep.

When a session was running, the excerpt also carries a kernel messages section from the <Language> Supervisor logs: every request the frontend sent to a kernel (execute_request with its code, comm_msg with its comm and method) in send order, plus execute busy/idle and lifecycle state changes. A kernel serves shell requests in the order they arrive, so this is what settles "did the code reach the kernel before the button's request did?" -- a test that presses Enter and then clicks has only dispatched both, and they can arrive in either order.

How the failing action is found. Positron's reporting fixture screenshots the page the instant the test function throws, so the failing action is whatever ended right before that screenshot: an errored call (not simply the first one -- a toPass or a page object's own retry logs every attempt it catches as an errored call, often long before the one that escaped), else a retry loop of identical read calls (the test's own assertion threw, as in expect(async () => { expect(await x.isVisible()).toBe(true) }).toPass() or expect.poll), else the screenshot alone as the deadline. The last two are inferred, and the console digest and log excerpt both say so in a line starting "The test failed on its own assertion". Without that screenshot (a passing retry) the first errored call is used, and with none the excerpt falls back to an error-line grep.

The decision rule that combines these -- and the requirement that the command-fired signal (or a confirmed-absent stable label), not DOM-absence alone, is what justifies a product-open-path verdict -- lives in the analysis rubric under "Action fired but nothing rendered."


Path B: posit-dev/positron-builds (S3 HTML Reports)

Process the HTML report (single script call)

The e2e-process-s3.js script handles everything in one call: fetches the report's index.html, decodes the embedded base64 report.zip, walks failures + per-file detail JSONs, downloads trace and error-context attachments from S3, parses traces, and extracts trailing screencast frames.

For each failed e2e job from Step 1, resolve the job's REPORT_DIR from its logs (the workflow logs both an unresolved template line containing literal ${IDENTIFIER} / ${OS_SUFFIX} and the expanded value -- ignore the template), then run:

node "$SKILL_DIR/scripts/e2e-process-s3.js" \
  --report-url https://positron-reports.tail00da2.ts.net/<REPORT_DIR>/ \
  --output-dir /tmp/e2e-analysis-<JOB_LABEL> \
  --cleanup

For interactive / ad-hoc use, you can call the script directly with any Playwright HTML report URL on the report server -- no run ID required, but you must be on the tailnet.

Output JSON is identical to Path A's e2e-process-project.js (see the field list above), so the same screenshot-reading and analysis flow applies. The blob field is the report directory name (last path segment of the S3 URL) rather than a zip filename, since Path B has no blob zips.

IMPORTANT: View screenshots the same way as Path A -- Read all screenshotPaths arrays in a single message with multiple parallel Read tool calls. Read the errorContextPath page snapshot FIRST for any locator-not-found / not-visible / attribute / text failure (it is the primary evidence for stale-selector vs product-regression -- see the analysis rubric), not just when screenshots and traces fall short.


Step 6: Query Historical Test Health (optional)

If E2E_INSIGHTS_API_KEY is set, query the e2e-test-insights dashboard for historical failure data. This step is optional -- if the API is unavailable, skip it and proceed with analysis. See CODE1 for auth, the repo_id convention, the test-key format, and how to read the response (insight.type, environment_breakdown, etc.) -- this section only covers the run-centric option specific to this skill.

Option 1: Query by workflow run ID (preferred)

If the GitHub run ID is available, use --run-id to get history for all tests that failed or flaked in this run:

node "$SKILL_DIR/scripts/e2e-query-history.js" --repo positron --run-id <RUN_ID> --lookback-days 14 --branch <BRANCH>

The branch is important -- a test may be rare_flake on main but known_flaky on a release branch. Get the branch from the run metadata (Step 1) or the onProject event in blob reports. Common branches: main, release/YYYY.MM.

Option 2: Query by test keys

If the run isn't in the dashboard yet, construct test keys manually from extracted failures -- see CODE0 for the key format and the JSON-array requirement:

node "$SKILL_DIR/scripts/e2e-query-history.js" --repo positron \
  --test-keys '["testName1|||specPath1", "testName2|||specPath2"]' --lookback-days 14

History line format

Include a History line in each failure's analysis, e.g.:


Step 7: Analyze and Present Results

For each failure (or group of related failures), apply the shared analysis rubric to determine its root-cause category, a 1-2 sentence evidence-based explanation, and a suggested action. rubric.md is the single source of truth for the root-cause categories, the evidence-reading order (screenshots, trace timeline, test source, and the error-context page snapshot -- read FIRST for any locator/visibility/attribute/text failure), the locator-drift-vs-product-regression decision, historical-data interpretation, and head-commit correlation. The same file is injected verbatim into the analyzer Action's system prompt, so local skill runs and the Action reason identically -- edit the rubric there, not here.

Include a Commit line in the detailed analysis when the head commit is relevant (per the rubric), e.g. "Commit: modified notebookCellList.ts (notebook cell rendering) -- plausible cause" or "Commit: no files related to this test's feature area -- unlikely cause".

When a failure's job had a pre-test setup failure (failedBeforeTest from Step 1), include a Setup line naming the step, e.g. "Setup: job step #23 Install R 4.4.0 failed and Install R packages for 4.4.0 was skipped -- this job's R tests ran without a working R". Lead with it: it determines the root cause and the owner before any other evidence matters.

Additional repo context

Also use context from the repo when helpful:

Key log files to check:

For each failure, include the platform (OS and project/browser) where it occurred. This information comes from:

When multiple projects/platforms are analyzed in a single run, note which platforms each failure occurred on and whether the same test passed on other platforms.

Deep-analyze the hard failures -- tests that failed all retries (failures in the extractor output, as opposed to failedTests, which includes attempts that recovered). Present them in a summary table with columns: test name, platform, root cause category, and severity (hard), then give the detailed per-failure analysis below the table.

Flaky tests (passed on retry) are not deep-analyzed here: they recovered on the same run, so they didn't break it, and per-test flaky investigation is the debug-e2e-test skill's specialty. List them compactly under a short "Flaky (passed on retry)" section (name + one-line history) and point to debug-e2e-test for any worth chasing -- unless the user explicitly asks you to dig into a flaky one. This keeps the run-centric analysis focused (and, in the Action, keeps token cost to the hard failures that actually need it).

Include non-e2e job failures (unit tests, integration tests, build failures) in the summary table as well, with the job name as the test name and a brief description of the failure extracted from the job logs.

Offer to:

Cleanup

Path A and Path B: If you used --cleanup with e2e-process-project.js / e2e-process-s3.js, the intermediate download/unzip dirs are already removed. Only the --output-dir remains (screenshots and error-context). Remove it with exact paths (no globs):

rm -rf /tmp/e2e-analysis-<PROJECT_OR_JOB_LABEL>
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.