← Back to Pull requests

fix(core): resolve axe.run when fake timers are installed #5518

Open
ifrederico opened this pull request with 200 lines diff across 2 files
View on GitHub
ifrederico ifrederico commented on Nov 02, 2026 17:14 UTC
Author

axe.run never resolves when a test installs fake timers after axe-core has loaded (e.g. jest.useFakeTimers() or sinon.useFakeTimers() inside a test). Rule#run defers resolving each rule with setTimeout(..., 0) (added in #1172 to avoid "unresponsive script" warnings), and with the global replaced by a fake that callback never fires.

This keeps a reference to setTimeout / clearTimeout from when axe-core loads (lib/core/utils/timers.js) and uses it for the rule deferral. Mocha keeps references to the timer functions for the same reason.

Notes:

  • The helpers are not added to axe.utils; they're exposed to tests through _thisWillBeDeletedDoNotUse, so there's no public API change.

  • Only the rule deferral changes. The frame-ping, frame-wait, and preload timeouts still use the globals: they only fire on failure, so they don't block a run, and existing tests in test/core/utils/send-command-to-frame.js and collect-results-from-frames.js stub window.setTimeout to drive them.

  • Fake timers installed before axe-core loads still hang, since the captured reference is already the fake. I asked in the issue whether an axe.configure option for that case is wanted; happy to add it here or in a follow-up.
  • Tests:

  • test/core/utils/timers.js unit tests, including with sinon fake timers installed

  • regression tests in test/core/base/rule.js and test/core/public/run.js; both time out without the fix and pass with it

  • pnpm test, test:jsdom, test:node, pnpm run eslint pass locally
  • Closes: #3055

    https://claude.ai/code/session_016WLtkULr1D35bPLkM1wCKn

    Diff: 200 lines (+150 / -50) across 2 files Reviewer: None requested Review duration: 44643m
    All Vouch review confidence checks passed
    Residual risk 0.32 = Change Risk (0.55) × (1 − Review Confidence (0.42)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 200 lines diff across 2 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 10%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.317
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Real PR Conversation Timeline
    1 comments
    "Review active on #5518"
    general weight: 0.35
    Reviewers
    None requested
    Assignees
    ifrederico ifrederico
    Labels
    risk: low confidence: 42.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 55.2% (MEDIUM) · Higher = larger blast radius
    55.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 42.2% · Lower = rushed or shallow review
    42.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 31.9% · Safe to merge
    31.9%