{
  "doc": {
    "id": "accessibility/guides/block-pull-requests",
    "title": "Block pull requests and set policies in Cypress Accessibility",
    "description": "Set policies and block pull requests automatically with Cypress Accessibility's Results API, enabling custom CI workflows to enforce accessibility standards and prevent regressions.",
    "section": "accessibility",
    "source_path": "/llm/markdown/accessibility/guides/block-pull-requests.md",
    "version": "c4ad6f88c531de58221c73dd91a75af7138334b8",
    "updated_at": "2026-11-10T01:15:02.829Z",
    "headings": [
      {
        "id": "accessibility/guides/block-pull-requests#block-pull-requests-and-set-policies",
        "text": "Block pull requests and set policies",
        "level": 1
      },
      {
        "id": "accessibility/guides/block-pull-requests#using-the-results-api",
        "text": "Using the Results API",
        "level": 2
      },
      {
        "id": "accessibility/guides/block-pull-requests#implementing-a-status-check",
        "text": "Implementing a status check",
        "level": 2
      },
      {
        "id": "accessibility/guides/block-pull-requests#defining-policies-in-the-verification-step",
        "text": "Defining policies in the verification step",
        "level": 2
      },
      {
        "id": "accessibility/guides/block-pull-requests#policy-block-any-rule-that-isnt-already-failing",
        "text": "Policy: block any rule that isn't already failing",
        "level": 3
      },
      {
        "id": "accessibility/guides/block-pull-requests#policy-block-regressions-in-rules-youve-fixed",
        "text": "Policy: block regressions in rules you've fixed",
        "level": 3
      },
      {
        "id": "accessibility/guides/block-pull-requests#using-profiles-for-pr-specific-configuration",
        "text": "Using Profiles for PR-specific configuration",
        "level": 2
      },
      {
        "id": "accessibility/guides/block-pull-requests#comparing-against-a-baseline",
        "text": "Comparing against a baseline",
        "level": 2
      },
      {
        "id": "accessibility/guides/block-pull-requests#baseline-structure",
        "text": "Baseline structure",
        "level": 3
      },
      {
        "id": "accessibility/guides/block-pull-requests#complete-example",
        "text": "Complete example",
        "level": 3
      },
      {
        "id": "accessibility/guides/block-pull-requests#key-concepts-in-the-example-script",
        "text": "Key concepts in the example script",
        "level": 3
      },
      {
        "id": "accessibility/guides/block-pull-requests#new-failing-rules",
        "text": "New failing rules",
        "level": 4
      },
      {
        "id": "accessibility/guides/block-pull-requests#resolved-rules",
        "text": "Resolved rules",
        "level": 4
      },
      {
        "id": "accessibility/guides/block-pull-requests#severity-filtering",
        "text": "Severity filtering",
        "level": 4
      },
      {
        "id": "accessibility/guides/block-pull-requests#view-level-comparison",
        "text": "View-level comparison",
        "level": 4
      },
      {
        "id": "accessibility/guides/block-pull-requests#best-practices",
        "text": "Best practices",
        "level": 3
      },
      {
        "id": "accessibility/guides/block-pull-requests#when-to-update-the-baseline",
        "text": "When to update the baseline",
        "level": 4
      },
      {
        "id": "accessibility/guides/block-pull-requests#handling-partial-reports",
        "text": "Handling partial reports",
        "level": 4
      },
      {
        "id": "accessibility/guides/block-pull-requests#managing-baseline-across-branches",
        "text": "Managing baseline across branches",
        "level": 4
      },
      {
        "id": "accessibility/guides/block-pull-requests#storing-the-baseline",
        "text": "Storing the baseline",
        "level": 4
      },
      {
        "id": "accessibility/guides/block-pull-requests#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "accessibility/guides/block-pull-requests#using-the-results-api",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Using the Results API",
      "heading_level": 2,
      "content_markdown": "## Using the Results API\n\nThe [Cypress Accessibility Results API](/llm/markdown/accessibility/connect-and-extend/results-api.md) returns accessibility results after a test run, enabling workflows like blocking pull requests or triggering alerts based on specific accessibility criteria. This involves adding a dedicated accessibility verification step to your CI pipeline. With a Cypress helper function, you can automatically fetch the report for the relevant test run within the CI build context. Below is an example of how to block a pull request in GitHub Actions if accessibility violations occur:\n",
      "section": "accessibility",
      "anchors": [
        "using-the-results-api"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 109
    },
    {
      "id": "accessibility/guides/block-pull-requests#implementing-a-status-check",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Implementing a status check",
      "heading_level": 2,
      "content_markdown": "## Implementing a status check\n\nThe Results API offers full flexibility to analyze results and take tailored actions. It can also integrate with status checks on pull requests. Below is an example of a passing accessibility verification step:\n",
      "section": "accessibility",
      "anchors": [
        "implementing-a-status-check"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 51
    },
    {
      "id": "accessibility/guides/block-pull-requests#defining-policies-in-the-verification-step",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Defining policies in the verification step",
      "heading_level": 2,
      "content_markdown": "## Defining policies in the verification step\n\nThe [Results API Documentation](/llm/markdown/accessibility/connect-and-extend/results-api.md) provides detailed guidance on the API's capabilities. Two rule-level policies cover most teams, and they're mirror images of each other. Both read `results.rules`, which lists only the rules that failed in the run.\n\n| Policy | Blocks when | Best for |\n| --- | --- | --- |\n| [Allowlist known failures](#Policy-block-any-rule-that-isnt-already-failing) | Any rule fails that isn't on your known-issues list | Reports that are close to clean, where anything unexpected should stop a merge |\n| [Protect what you've fixed](#Policy-block-regressions-in-rules-youve-fixed) | A rule you already remediated fails again | A large backlog you're working through, where most rules still fail |\n\nFor a policy that tracks violations per view rather than per rule, see [comparing against a baseline](#comparing-against-a-baseline).\n\n### Policy: block any rule that isn't already failing\n\nThis enforces \"no new failing accessibility rules\". You keep a list of the rules you already know about, and anything outside it fails the build:\n\n```\nconst { getAccessibilityResults } = require('@cypress/extract-cloud-results')\n\n// List of known failing rules\nconst rulesWithExistingViolations = [\n  'button-name',\n  // Add more rules as needed\n]\n\n// Fetch accessibility results\ngetAccessibilityResults().then((results) => {\n  // Identify new rule violations\n  const newRuleViolations = results.rules.filter((rule) => {\n    return !rulesWithExistingViolations.includes(rule.name)\n  })\n\n  if (newRuleViolations.length > 0) {\n    // Trigger appropriate action if new violations are detected\n    throw new Error(\n      `${newRuleViolations.length} new rule violations detected. These must be resolved.`\n    )\n  }\n})\n```\n\nThe list shrinks as you fix things, and every entry you remove raises the standard the build enforces.\n\n### Policy: block regressions in rules you've fixed\n\nThis is the inverse, and it suits a project still working through a large backlog. Rather than listing what's broken, you list what you've finished, and only a reappearance of those rules fails the build:\n\nscripts/verifyAccessibilityResults.js\n\n```\nconst { getAccessibilityResults } = require('@cypress/extract-cloud-results')\n\n// Rules this team has remediated. Add a rule here the day it reaches zero\n// violations, so any reappearance is treated as a regression.\nconst remediatedRules = ['button-name', 'image-alt', 'label']\n\ngetAccessibilityResults().then((results) => {\n  const regressions = results.rules.filter((rule) =>\n    remediatedRules.includes(rule.name)\n  )\n\n  if (regressions.length === 0) {\n    console.log(`No regressions in ${remediatedRules.length} remediated rules.`)\n    return\n  }\n\n  console.error('Previously remediated accessibility rules are failing again:')\n  regressions.forEach((rule) => {\n    console.error(\n      `  - ${rule.name} (${rule.severity}): ${rule.accessibilityReportUrl}`\n    )\n  })\n\n  throw new Error(\n    `${regressions.length} remediated rule(s) regressed and must be fixed before merging.`\n  )\n})\n```\n\nHere the list grows as you work. It never blocks a merge for a rule you haven't gotten to yet, which keeps the gate credible while the backlog is still large. See [Fix accessibility violations](/llm/markdown/accessibility/guides/improve-accessibility.md) for how to work through that backlog one rule at a time.\n\nBy examining the results and customizing your response, you gain maximum control over how to handle accessibility violations. Use CI environment context, such as tags, to fine-tune responses to specific accessibility outcomes.\n",
      "section": "accessibility",
      "anchors": [
        "defining-policies-in-the-verification-step"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 637
    },
    {
      "id": "accessibility/guides/block-pull-requests#policy-block-any-rule-that-isnt-already-failing",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Policy: block any rule that isn't already failing",
      "heading_level": 3,
      "content_markdown": "### Policy: block any rule that isn't already failing\n\nThis enforces \"no new failing accessibility rules\". You keep a list of the rules you already know about, and anything outside it fails the build:\n\n```\nconst { getAccessibilityResults } = require('@cypress/extract-cloud-results')\n\n// List of known failing rules\nconst rulesWithExistingViolations = [\n  'button-name',\n  // Add more rules as needed\n]\n\n// Fetch accessibility results\ngetAccessibilityResults().then((results) => {\n  // Identify new rule violations\n  const newRuleViolations = results.rules.filter((rule) => {\n    return !rulesWithExistingViolations.includes(rule.name)\n  })\n\n  if (newRuleViolations.length > 0) {\n    // Trigger appropriate action if new violations are detected\n    throw new Error(\n      `${newRuleViolations.length} new rule violations detected. These must be resolved.`\n    )\n  }\n})\n```\n\nThe list shrinks as you fix things, and every entry you remove raises the standard the build enforces.\n",
      "section": "accessibility",
      "anchors": [
        "policy-block-any-rule-that-isnt-already-failing"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 171
    },
    {
      "id": "accessibility/guides/block-pull-requests#policy-block-regressions-in-rules-youve-fixed",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Policy: block regressions in rules you've fixed",
      "heading_level": 3,
      "content_markdown": "### Policy: block regressions in rules you've fixed\n\nThis is the inverse, and it suits a project still working through a large backlog. Rather than listing what's broken, you list what you've finished, and only a reappearance of those rules fails the build:\n\nscripts/verifyAccessibilityResults.js\n\n```\nconst { getAccessibilityResults } = require('@cypress/extract-cloud-results')\n\n// Rules this team has remediated. Add a rule here the day it reaches zero\n// violations, so any reappearance is treated as a regression.\nconst remediatedRules = ['button-name', 'image-alt', 'label']\n\ngetAccessibilityResults().then((results) => {\n  const regressions = results.rules.filter((rule) =>\n    remediatedRules.includes(rule.name)\n  )\n\n  if (regressions.length === 0) {\n    console.log(`No regressions in ${remediatedRules.length} remediated rules.`)\n    return\n  }\n\n  console.error('Previously remediated accessibility rules are failing again:')\n  regressions.forEach((rule) => {\n    console.error(\n      `  - ${rule.name} (${rule.severity}): ${rule.accessibilityReportUrl}`\n    )\n  })\n\n  throw new Error(\n    `${regressions.length} remediated rule(s) regressed and must be fixed before merging.`\n  )\n})\n```\n\nHere the list grows as you work. It never blocks a merge for a rule you haven't gotten to yet, which keeps the gate credible while the backlog is still large. See [Fix accessibility violations](/llm/markdown/accessibility/guides/improve-accessibility.md) for how to work through that backlog one rule at a time.\n\nBy examining the results and customizing your response, you gain maximum control over how to handle accessibility violations. Use CI environment context, such as tags, to fine-tune responses to specific accessibility outcomes.\n",
      "section": "accessibility",
      "anchors": [
        "policy-block-regressions-in-rules-youve-fixed"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 291
    },
    {
      "id": "accessibility/guides/block-pull-requests#using-profiles-for-pr-specific-configuration",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Using Profiles for PR-specific configuration",
      "heading_level": 2,
      "content_markdown": "## Using Profiles for PR-specific configuration\n\nYou can use [Profiles](/llm/markdown/accessibility/configuration/profiles.md) to apply different configuration settings for pull request runs versus regression runs. This approach supports several patterns:\n\n*   Use a narrow, focused configuration for PR runs that blocks merges based on critical accessibility issues\n*   Maintain a broader configuration for regression runs that tracks all issues for long-term monitoring\n*   Apply team-specific configurations when multiple teams share the same Cypress Cloud project\n\nFor example, a profile named `aq-config-pr` can narrow pull request reports to a single flow that's under active remediation, while your base configuration keeps every page for regression tracking. The first rule includes the flow and the catch-all `*` rule excludes everything else, because [`viewFilters`](/llm/markdown/accessibility/configuration/viewfilters.md) apply in order and the first match wins:\n\nApp Quality Config\n\n```\n{\n  \"profiles\": [\n    {\n      \"name\": \"aq-config-pr\",\n      \"comment\": \"Pull request runs report only on the checkout flow while we remediate it\",\n      \"config\": {\n        \"viewFilters\": [\n          {\n            \"pattern\": \"/checkout/*\",\n            \"include\": true\n          },\n          {\n            \"pattern\": \"*\",\n            \"include\": false\n          }\n        ]\n      }\n    }\n  ]\n}\n```\n\nRecord pull request runs with the matching tag to select the profile:\n\n```\ncypress run --record --tag \"aq-config-pr\"\n```\n\nThis approach ensures that PR checks are fast and focused, while still maintaining comprehensive reporting for your full test suite. A profile can also set [`axeConfig`](/llm/markdown/accessibility/configuration/axe-core-configuration.md) under `accessibility` if you want pull request runs to use a different Axe-Core® ruleset than regression runs. Which findings block a merge still stays a decision you make in the verification step above.\n",
      "section": "accessibility",
      "anchors": [
        "using-profiles-for-pr-specific-configuration"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 332
    },
    {
      "id": "accessibility/guides/block-pull-requests#comparing-against-a-baseline",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Comparing against a baseline",
      "heading_level": 2,
      "content_markdown": "## Comparing against a baseline\n\nComparing current results against a stored baseline surfaces only the new violations that have been introduced, while ignoring existing known issues. This approach is more sophisticated than simply maintaining a list of known failing rules, as it tracks violations at the view level and can detect both regressions (new violations) and improvements (resolved violations).\n\nThis is particularly useful in CI/CD pipelines where you want to fail builds only when new accessibility violations are introduced, so existing issues can be addressed incrementally without blocking deployments.\n\n### Baseline structure\n\nYou can use any format you like as baseline for comparing reports. In the example code below we generate a baseline in a simplified format, which captures the state of accessibility violations from a specific run. The Results API handler code logs this for every run so that it can be copied as a new reference point.\n\nIt includes:\n\n*   **runNumber**: The run number used as the baseline reference\n*   **severityLevels**: The severity levels to track (e.g., `['critical', 'serious', 'moderate', 'minor']`)\n*   **views**: An object mapping view display names to arrays of failed rule names for that view\n\n```\n{\n  \"runNumber\": \"111\",\n  \"severityLevels\": [\n    \"critical\",\n    \"serious\",\n    \"moderate\",\n    \"minor\"\n  ],\n  \"views\": {\n    \"/\": [\n      \"aria-dialog-name\",\n      \"heading-order\",\n      \"scrollable-region-focusable\"\n    ],\n    \"/authorizations\": [\n      \"heading-order\",\n      \"listitem\",\n      \"region\"\n    ]\n  }\n}\n```\n\n### Complete example\n\nThe following example demonstrates how to compare current results against a baseline, detect new violations, identify resolved violations, and generate a new baseline when changes are detected.\n\nscripts/compareAccessibilityBaseline.js\n\n```\nrequire('dotenv').config()\n\nconst { getAccessibilityResults } = require('@cypress/extract-cloud-results')\nconst fs = require('fs')\n\nconst TARGET_SEVERITY_LEVELS = ['critical', 'serious', 'moderate', 'minor']\n\n// Parse the run number from an accessibility report URL\nconst parseRunNumber = (url) => {\n  return url.split('runs/')[1].split('/accessibility')[0]\n}\n\n// Define your baseline - beginning with no details\n// will list all current violations as \"new\", and log a\n// baseline that you can copy and save as your starting point\n\nconst baseline = {\n  runNumber: '',\n  severityLevels: ['critical', 'serious', 'moderate', 'minor'],\n  views: {},\n}\n\ngetAccessibilityResults().then((results) => {\n  // Create objects to store the results\n  const viewRules = {}\n  const viewsWithNewFailedRules = {}\n  const viewsWithMissingRules = {}\n\n  // Iterate through each view in current results\n  results.views.forEach((view) => {\n    const displayName = view.displayName\n    const ruleNames = view.rules.map((rule) => rule.name)\n\n    // Add to our results object\n    viewRules[displayName] = ruleNames\n\n    // Check for new failing rules\n    if (view.rules.length) {\n      view.rules.forEach((rule) => {\n        if (!TARGET_SEVERITY_LEVELS.includes(rule.severity)) {\n          return\n        }\n\n        // If the view exists in baseline and the rule is not in baseline's failed rules\n        if (!baseline.views?.[displayName]?.includes(rule.name)) {\n          if (viewsWithNewFailedRules[displayName]) {\n            viewsWithNewFailedRules[displayName].newFailedRules.push({\n              name: rule.name,\n              url: rule.accessibilityReportUrl,\n            })\n          } else {\n            viewsWithNewFailedRules[displayName] = {\n              newFailedRules: [\n                {\n                  name: rule.name,\n                  url: rule.accessibilityReportUrl,\n                },\n              ],\n            }\n          }\n        }\n      })\n    }\n  })\n\n  // Check for rules in baseline that are not in current results (resolved rules)\n  Object.entries(baseline.views).forEach(([displayName, baselineRules]) => {\n    const currentRules = viewRules[displayName] || []\n    const resolvedRules = baselineRules.filter(\n      (rule) => !currentRules.includes(rule)\n    )\n\n    if (resolvedRules.length > 0) {\n      viewsWithMissingRules[displayName] = { resolvedRules }\n    }\n  })\n\n  // Report any missing rules\n  const countOfViewsWithMissingRules = Object.keys(viewsWithMissingRules).length\n  const countOfViewsWithNewFailedRules = Object.keys(\n    viewsWithNewFailedRules\n  ).length\n\n  if (countOfViewsWithMissingRules || countOfViewsWithNewFailedRules) {\n    // Generate and log the new baseline values if there has been a change\n    const newBaseline = generateBaseline(results)\n    console.log('\\nTo use this run as the new baseline, copy these values:')\n    console.log(JSON.stringify(newBaseline, null, 2))\n    fs.writeFileSync('new-baseline.json', JSON.stringify(newBaseline, null, 2))\n  }\n\n  if (countOfViewsWithMissingRules) {\n    console.log(\n      '\\nThe following Views had rules in the baseline that are no longer failing. This may be due to improvements in these rules, or because you did not run as many tests in this run as the baseline run:'\n    )\n    console.dir(viewsWithMissingRules, { depth: 3 })\n  } else if (!countOfViewsWithNewFailedRules) {\n    console.log(\n      '\\nNo new or resolved rules were detected. All violations match the baseline.\\n'\n    )\n  }\n\n  if (countOfViewsWithNewFailedRules) {\n    // Report any new failing rules\n    console.error(\n      '\\nThe following Views had rules violated that were previously passing:'\n    )\n    console.dir(viewsWithNewFailedRules, { depth: 3 })\n    throw new Error(\n      `${countOfViewsWithNewFailedRules} Views contained new failing accessibility rules.`\n    )\n  }\n\n  return viewRules\n})\n\nfunction generateBaseline(results) {\n  try {\n    // Create an object to store the results\n    const viewRules = {}\n\n    // Iterate through each view\n    results.views.forEach((view) => {\n      // Get the displayName and extract the rule names\n      const displayName = view.displayName\n      const ruleNames = view.rules\n        .filter((rule) => TARGET_SEVERITY_LEVELS.includes(rule.severity))\n        .map((rule) => rule.name)\n\n      // Add to our results object\n      viewRules[displayName] = ruleNames\n    })\n\n    const runNumber = parseRunNumber(results.views[0].accessibilityReportUrl)\n\n    return {\n      runNumber,\n      severityLevels: TARGET_SEVERITY_LEVELS,\n      views: viewRules,\n    }\n  } catch (error) {\n    console.error('Error parsing accessibility results:', error)\n    return null\n  }\n}\n```\n\n### Key concepts in the example script\n\n#### New failing rules\n\nA **new failing rule** is a rule that has violations on a View in the current run that were not present in the baseline. These represent regressions that need to be addressed. The script will fail the build if any new failing rules are detected.\n\n#### Resolved rules\n\nA **resolved rule** is a rule that was present in the baseline but no longer has violations in the current run. These represent improvements in accessibility. The script reports these but does not fail the build, tracking your progress and printing out an updated baseline to copy over when things are fixed.\n\n#### Severity filtering\n\nThe baseline comparison only tracks rules at the severity levels you specify in `TARGET_SEVERITY_LEVELS`. This keeps the comparison focused on the severity levels that matter most to your team. Rules at other severity levels are ignored during comparison.\n\n#### View-level comparison\n\nViolations are tracked per view (URL pattern or component), pinpointing exactly which pages or components have regressed or improved. This granular tracking makes it easier to identify the source of changes and assign fixes to the appropriate teams.\n\n### Best practices\n\n#### When to update the baseline\n\nUpdate your baseline when:\n\n*   You've fixed accessibility violations and want to prevent regressions\n*   You've accepted certain violations as known issues that won't block deployments\n\nWe recommend storing the baseline in version control so it's versioned alongside your code and accessible in CI environments, but some users prefer updating the baseline automatically based on the newest results from a full passing test run on the main branch of the project. This means any PRs will be compared against the reference run that makes sense at the time the results are analyzed, and avoids needing to manually own the standard.\n\n#### Handling partial reports\n\nIf a run is cancelled or incomplete, the Results API may return a partial report. Consider checking `summary.isPartialReport` before comparing against the baseline, as partial reports may not include all views and could produce false positives.\n\n#### Managing baseline across branches\n\nYou may want different baselines for different branches (e.g., `main` vs feature branches). Consider storing baselines in branch-specific files or using environment variables to specify which baseline to use.\n\n#### Storing the baseline\n\nCommon approaches for storing baselines:\n\n*   **Version control**: Commit the baseline JSON file to your repository\n*   **CI artifacts**: Store baselines as build artifacts that can be retrieved in subsequent runs\n",
      "section": "accessibility",
      "anchors": [
        "comparing-against-a-baseline"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 1541
    },
    {
      "id": "accessibility/guides/block-pull-requests#baseline-structure",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Baseline structure",
      "heading_level": 3,
      "content_markdown": "### Baseline structure\n\nYou can use any format you like as baseline for comparing reports. In the example code below we generate a baseline in a simplified format, which captures the state of accessibility violations from a specific run. The Results API handler code logs this for every run so that it can be copied as a new reference point.\n\nIt includes:\n\n*   **runNumber**: The run number used as the baseline reference\n*   **severityLevels**: The severity levels to track (e.g., `['critical', 'serious', 'moderate', 'minor']`)\n*   **views**: An object mapping view display names to arrays of failed rule names for that view\n\n```\n{\n  \"runNumber\": \"111\",\n  \"severityLevels\": [\n    \"critical\",\n    \"serious\",\n    \"moderate\",\n    \"minor\"\n  ],\n  \"views\": {\n    \"/\": [\n      \"aria-dialog-name\",\n      \"heading-order\",\n      \"scrollable-region-focusable\"\n    ],\n    \"/authorizations\": [\n      \"heading-order\",\n      \"listitem\",\n      \"region\"\n    ]\n  }\n}\n```\n",
      "section": "accessibility",
      "anchors": [
        "baseline-structure"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 172
    },
    {
      "id": "accessibility/guides/block-pull-requests#complete-example",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Complete example",
      "heading_level": 3,
      "content_markdown": "### Complete example\n\nThe following example demonstrates how to compare current results against a baseline, detect new violations, identify resolved violations, and generate a new baseline when changes are detected.\n\nscripts/compareAccessibilityBaseline.js\n\n```\nrequire('dotenv').config()\n\nconst { getAccessibilityResults } = require('@cypress/extract-cloud-results')\nconst fs = require('fs')\n\nconst TARGET_SEVERITY_LEVELS = ['critical', 'serious', 'moderate', 'minor']\n\n// Parse the run number from an accessibility report URL\nconst parseRunNumber = (url) => {\n  return url.split('runs/')[1].split('/accessibility')[0]\n}\n\n// Define your baseline - beginning with no details\n// will list all current violations as \"new\", and log a\n// baseline that you can copy and save as your starting point\n\nconst baseline = {\n  runNumber: '',\n  severityLevels: ['critical', 'serious', 'moderate', 'minor'],\n  views: {},\n}\n\ngetAccessibilityResults().then((results) => {\n  // Create objects to store the results\n  const viewRules = {}\n  const viewsWithNewFailedRules = {}\n  const viewsWithMissingRules = {}\n\n  // Iterate through each view in current results\n  results.views.forEach((view) => {\n    const displayName = view.displayName\n    const ruleNames = view.rules.map((rule) => rule.name)\n\n    // Add to our results object\n    viewRules[displayName] = ruleNames\n\n    // Check for new failing rules\n    if (view.rules.length) {\n      view.rules.forEach((rule) => {\n        if (!TARGET_SEVERITY_LEVELS.includes(rule.severity)) {\n          return\n        }\n\n        // If the view exists in baseline and the rule is not in baseline's failed rules\n        if (!baseline.views?.[displayName]?.includes(rule.name)) {\n          if (viewsWithNewFailedRules[displayName]) {\n            viewsWithNewFailedRules[displayName].newFailedRules.push({\n              name: rule.name,\n              url: rule.accessibilityReportUrl,\n            })\n          } else {\n            viewsWithNewFailedRules[displayName] = {\n              newFailedRules: [\n                {\n                  name: rule.name,\n                  url: rule.accessibilityReportUrl,\n                },\n              ],\n            }\n          }\n        }\n      })\n    }\n  })\n\n  // Check for rules in baseline that are not in current results (resolved rules)\n  Object.entries(baseline.views).forEach(([displayName, baselineRules]) => {\n    const currentRules = viewRules[displayName] || []\n    const resolvedRules = baselineRules.filter(\n      (rule) => !currentRules.includes(rule)\n    )\n\n    if (resolvedRules.length > 0) {\n      viewsWithMissingRules[displayName] = { resolvedRules }\n    }\n  })\n\n  // Report any missing rules\n  const countOfViewsWithMissingRules = Object.keys(viewsWithMissingRules).length\n  const countOfViewsWithNewFailedRules = Object.keys(\n    viewsWithNewFailedRules\n  ).length\n\n  if (countOfViewsWithMissingRules || countOfViewsWithNewFailedRules) {\n    // Generate and log the new baseline values if there has been a change\n    const newBaseline = generateBaseline(results)\n    console.log('\\nTo use this run as the new baseline, copy these values:')\n    console.log(JSON.stringify(newBaseline, null, 2))\n    fs.writeFileSync('new-baseline.json', JSON.stringify(newBaseline, null, 2))\n  }\n\n  if (countOfViewsWithMissingRules) {\n    console.log(\n      '\\nThe following Views had rules in the baseline that are no longer failing. This may be due to improvements in these rules, or because you did not run as many tests in this run as the baseline run:'\n    )\n    console.dir(viewsWithMissingRules, { depth: 3 })\n  } else if (!countOfViewsWithNewFailedRules) {\n    console.log(\n      '\\nNo new or resolved rules were detected. All violations match the baseline.\\n'\n    )\n  }\n\n  if (countOfViewsWithNewFailedRules) {\n    // Report any new failing rules\n    console.error(\n      '\\nThe following Views had rules violated that were previously passing:'\n    )\n    console.dir(viewsWithNewFailedRules, { depth: 3 })\n    throw new Error(\n      `${countOfViewsWithNewFailedRules} Views contained new failing accessibility rules.`\n    )\n  }\n\n  return viewRules\n})\n\nfunction generateBaseline(results) {\n  try {\n    // Create an object to store the results\n    const viewRules = {}\n\n    // Iterate through each view\n    results.views.forEach((view) => {\n      // Get the displayName and extract the rule names\n      const displayName = view.displayName\n      const ruleNames = view.rules\n        .filter((rule) => TARGET_SEVERITY_LEVELS.includes(rule.severity))\n        .map((rule) => rule.name)\n\n      // Add to our results object\n      viewRules[displayName] = ruleNames\n    })\n\n    const runNumber = parseRunNumber(results.views[0].accessibilityReportUrl)\n\n    return {\n      runNumber,\n      severityLevels: TARGET_SEVERITY_LEVELS,\n      views: viewRules,\n    }\n  } catch (error) {\n    console.error('Error parsing accessibility results:', error)\n    return null\n  }\n}\n```\n",
      "section": "accessibility",
      "anchors": [
        "complete-example"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 703
    },
    {
      "id": "accessibility/guides/block-pull-requests#key-concepts-in-the-example-script",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Key concepts in the example script",
      "heading_level": 3,
      "content_markdown": "### Key concepts in the example script\n\n#### New failing rules\n\nA **new failing rule** is a rule that has violations on a View in the current run that were not present in the baseline. These represent regressions that need to be addressed. The script will fail the build if any new failing rules are detected.\n\n#### Resolved rules\n\nA **resolved rule** is a rule that was present in the baseline but no longer has violations in the current run. These represent improvements in accessibility. The script reports these but does not fail the build, tracking your progress and printing out an updated baseline to copy over when things are fixed.\n\n#### Severity filtering\n\nThe baseline comparison only tracks rules at the severity levels you specify in `TARGET_SEVERITY_LEVELS`. This keeps the comparison focused on the severity levels that matter most to your team. Rules at other severity levels are ignored during comparison.\n\n#### View-level comparison\n\nViolations are tracked per view (URL pattern or component), pinpointing exactly which pages or components have regressed or improved. This granular tracking makes it easier to identify the source of changes and assign fixes to the appropriate teams.\n",
      "section": "accessibility",
      "anchors": [
        "key-concepts-in-the-example-script"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 257
    },
    {
      "id": "accessibility/guides/block-pull-requests#new-failing-rules",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "New failing rules",
      "heading_level": 4,
      "content_markdown": "#### New failing rules\n\nA **new failing rule** is a rule that has violations on a View in the current run that were not present in the baseline. These represent regressions that need to be addressed. The script will fail the build if any new failing rules are detected.\n",
      "section": "accessibility",
      "anchors": [
        "new-failing-rules"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 65
    },
    {
      "id": "accessibility/guides/block-pull-requests#resolved-rules",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Resolved rules",
      "heading_level": 4,
      "content_markdown": "#### Resolved rules\n\nA **resolved rule** is a rule that was present in the baseline but no longer has violations in the current run. These represent improvements in accessibility. The script reports these but does not fail the build, tracking your progress and printing out an updated baseline to copy over when things are fixed.\n",
      "section": "accessibility",
      "anchors": [
        "resolved-rules"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 73
    },
    {
      "id": "accessibility/guides/block-pull-requests#severity-filtering",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Severity filtering",
      "heading_level": 4,
      "content_markdown": "#### Severity filtering\n\nThe baseline comparison only tracks rules at the severity levels you specify in `TARGET_SEVERITY_LEVELS`. This keeps the comparison focused on the severity levels that matter most to your team. Rules at other severity levels are ignored during comparison.\n",
      "section": "accessibility",
      "anchors": [
        "severity-filtering"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 55
    },
    {
      "id": "accessibility/guides/block-pull-requests#view-level-comparison",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "View-level comparison",
      "heading_level": 4,
      "content_markdown": "#### View-level comparison\n\nViolations are tracked per view (URL pattern or component), pinpointing exactly which pages or components have regressed or improved. This granular tracking makes it easier to identify the source of changes and assign fixes to the appropriate teams.\n",
      "section": "accessibility",
      "anchors": [
        "view-level-comparison"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 55
    },
    {
      "id": "accessibility/guides/block-pull-requests#best-practices",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Best practices",
      "heading_level": 3,
      "content_markdown": "### Best practices\n\n#### When to update the baseline\n\nUpdate your baseline when:\n\n*   You've fixed accessibility violations and want to prevent regressions\n*   You've accepted certain violations as known issues that won't block deployments\n\nWe recommend storing the baseline in version control so it's versioned alongside your code and accessible in CI environments, but some users prefer updating the baseline automatically based on the newest results from a full passing test run on the main branch of the project. This means any PRs will be compared against the reference run that makes sense at the time the results are analyzed, and avoids needing to manually own the standard.\n\n#### Handling partial reports\n\nIf a run is cancelled or incomplete, the Results API may return a partial report. Consider checking `summary.isPartialReport` before comparing against the baseline, as partial reports may not include all views and could produce false positives.\n\n#### Managing baseline across branches\n\nYou may want different baselines for different branches (e.g., `main` vs feature branches). Consider storing baselines in branch-specific files or using environment variables to specify which baseline to use.\n\n#### Storing the baseline\n\nCommon approaches for storing baselines:\n\n*   **Version control**: Commit the baseline JSON file to your repository\n*   **CI artifacts**: Store baselines as build artifacts that can be retrieved in subsequent runs\n",
      "section": "accessibility",
      "anchors": [
        "best-practices"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 291
    },
    {
      "id": "accessibility/guides/block-pull-requests#when-to-update-the-baseline",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "When to update the baseline",
      "heading_level": 4,
      "content_markdown": "#### When to update the baseline\n\nUpdate your baseline when:\n\n*   You've fixed accessibility violations and want to prevent regressions\n*   You've accepted certain violations as known issues that won't block deployments\n\nWe recommend storing the baseline in version control so it's versioned alongside your code and accessible in CI environments, but some users prefer updating the baseline automatically based on the newest results from a full passing test run on the main branch of the project. This means any PRs will be compared against the reference run that makes sense at the time the results are analyzed, and avoids needing to manually own the standard.\n",
      "section": "accessibility",
      "anchors": [
        "when-to-update-the-baseline"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 141
    },
    {
      "id": "accessibility/guides/block-pull-requests#handling-partial-reports",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Handling partial reports",
      "heading_level": 4,
      "content_markdown": "#### Handling partial reports\n\nIf a run is cancelled or incomplete, the Results API may return a partial report. Consider checking `summary.isPartialReport` before comparing against the baseline, as partial reports may not include all views and could produce false positives.\n",
      "section": "accessibility",
      "anchors": [
        "handling-partial-reports"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 53
    },
    {
      "id": "accessibility/guides/block-pull-requests#managing-baseline-across-branches",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Managing baseline across branches",
      "heading_level": 4,
      "content_markdown": "#### Managing baseline across branches\n\nYou may want different baselines for different branches (e.g., `main` vs feature branches). Consider storing baselines in branch-specific files or using environment variables to specify which baseline to use.\n",
      "section": "accessibility",
      "anchors": [
        "managing-baseline-across-branches"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 45
    },
    {
      "id": "accessibility/guides/block-pull-requests#storing-the-baseline",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "Storing the baseline",
      "heading_level": 4,
      "content_markdown": "#### Storing the baseline\n\nCommon approaches for storing baselines:\n\n*   **Version control**: Commit the baseline JSON file to your repository\n*   **CI artifacts**: Store baselines as build artifacts that can be retrieved in subsequent runs\n",
      "section": "accessibility",
      "anchors": [
        "storing-the-baseline"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 47
    },
    {
      "id": "accessibility/guides/block-pull-requests#see-also",
      "doc_id": "accessibility/guides/block-pull-requests",
      "heading": "See also",
      "heading_level": 2,
      "content_markdown": "## See also\n\n*   [Run Checks](/llm/markdown/cloud/features/checks.md) - declarative accessibility score and failed-element thresholds\n*   [Report Run Checks as GitHub pull request statuses](/llm/markdown/accessibility/guides/report-run-checks-github.md) - post each check as a required commit status\n*   [Results API](/llm/markdown/accessibility/connect-and-extend/results-api.md) - fetch per-rule and per-view results for custom policies\n",
      "section": "accessibility",
      "anchors": [
        "see-also"
      ],
      "path": "/llm/json/chunked/accessibility/guides/block-pull-requests.json",
      "token_estimate": 57
    }
  ]
}