fix(core): resolve axe.run when fake timers are installed #5518
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 10%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
ifrederico
axe.runnever resolves when a test installs fake timers after axe-core has loaded (e.g.jest.useFakeTimers()orsinon.useFakeTimers()inside a test).Rule#rundefers resolving each rule withsetTimeout(..., 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/clearTimeoutfrom 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:
axe.utils; they're exposed to tests through_thisWillBeDeletedDoNotUse, so there's no public API change.test/core/utils/send-command-to-frame.jsandcollect-results-from-frames.jsstubwindow.setTimeoutto drive them.axe.configureoption for that case is wanted; happy to add it here or in a follow-up.Tests:
test/core/utils/timers.jsunit tests, including with sinon fake timers installedtest/core/base/rule.jsandtest/core/public/run.js; both time out without the fix and pass with itpnpm test,test:jsdom,test:node,pnpm run eslintpass locallyCloses: #3055
https://claude.ai/code/session_016WLtkULr1D35bPLkM1wCKn