Start with real code
One target file, from a small algorithm to a 4,218-line application component.
A visual guide to RefactorBench-JS
Refactoring should change how code is organized—not what the software does. RefactorBench-JS checks that promise by giving coding agents large JavaScript and React files, then testing the behavior they were supposed to preserve.
01 · The basic idea
A refactor can look cleaner and still break a button, change an API response, or lose saved state. RefactorBench keeps the agent away from the holdout tests, then runs those tests after the work is finished.
One target file, from a small algorithm to a 4,218-line application component.
The agent can create modules, move logic, and reconnect the pieces.
The agent cannot optimize for the exact assertions used to grade it.
Passing means the observable behavior survived the reorganization.
The benchmark’s rule of thumb “Behavioral preservation is a functional property, and functional properties are best verified by functional tests.”
02 · What gets tested
The fixtures span pure logic, data, APIs, web interfaces, and mobile apps. The test changes with the kind of behavior that matters.
Edge cases, return values, and data-structure invariants must stay intact.
Rendering, events, browser storage, and multi-step user flows are exercised.
Navigation, gestures, native APIs, modals, and mobile state flows are checked.
03 · Baseline results
Seven model configurations attempted the same 123 fixtures, once with a unit-test runner available and once without it. Toggle the chart to compare them.
Hidden-test pass rate. Every model/tool condition used the same 123 fixtures.
Sonnet 4.6 passed 29 fixtures with the runner and 17 without it.
Two models scored slightly lower with the test runner available.
Failed in all 14 baseline conditions; large UI files dominated this group.
04 · The trust gap
In the highest-scoring baseline condition, the agent reported success far more often than the hidden tests confirmed preserved behavior.
Gemini 3.0 Pro with the test runner enabled.
The external behavioral check tells a different story.
The agent reported success, but the hidden tests still found broken behavior.
05 · Where attempts failed
Across 1,436 failed outcomes, incomplete attempts, syntax errors, and broken module boundaries explained more than nine out of ten failures.
06 · What it means
A coding agent also depends on its tools, its stopping behavior, and the external checks around it. RefactorBench makes those differences measurable instead of trusting a clean-looking diff or a confident completion message.
Run the code. Compilation and visual cleanliness cannot prove behavior survived.
Evaluate model + tools together. The same tool can help one model and fail to help another.
Measure calibration. An agent that knows when it failed is safer than one that breaks things confidently.