How Airbnb Migrated 3.5K Enzyme Tests to React Testing Library in Six Weeks Using LLM‑Powered Automation
Airbnb transformed nearly 3,500 Enzyme test files to React Testing Library in just six weeks by building a large‑language‑model‑driven pipeline that validates, rewrites, retries, and enriches prompts with extensive context, achieving a 97% migration success rate while dramatically cutting manual effort and cost.
Background
In 2020 Airbnb began adopting React Testing Library (RTL) for new component tests, moving away from Enzyme, which was designed for older React versions. Because Enzyme and RTL differ fundamentally, a simple replacement was impossible and deleting Enzyme tests would have created a significant coverage gap.
How the Migration Was Done
During a 2023 hackathon a team proved that large language models (LLMs) could convert hundreds of Enzyme files to RTL in a few days. Building on that, Airbnb created a scalable, LLM‑driven migration pipeline in 2024. The pipeline breaks the migration into parallel, per‑file steps, adds configurable retry loops, and expands prompts with rich context, especially for long‑tail files.
File Validation and Refactoring Steps
The process is modeled as a state machine: each file passes through sequential validation stages (Enzyme refactor, Jest fix, lint fix, TypeScript check) and only advances when the previous stage succeeds. When a check fails, the LLM is invoked to repair the file.
This step‑wise approach enables progress tracking, failure‑rate improvement, and easy re‑running of individual steps, allowing concurrent migration of hundreds of files.
Retry Loops and Dynamic Prompts
Early attempts at prompt engineering showed limited gains; instead, a brute‑force strategy of retrying each step up to a limit proved most effective. Each retry supplies the LLM with the latest validation error and file version via dynamic prompts, and a loop runner enforces the retry limit.
Most simple to medium‑complexity files succeeded within ten retries, and many completed after just a few attempts.
Expanded Context
For more complex files, the prompts were enlarged to 40 000–100 000 tokens, incorporating up to 50 related files, a suite of hand‑crafted few‑shot examples, and well‑tested examples from the same project. Each prompt includes:
Source code of the component under test
The test file to migrate
Validation failure messages
Nearby tests from the same directory (preserving team patterns)
General migration guidelines and common solutions
// Code example shows a trimmed down version of a prompt
// including the raw source code from related files, imports,
// examples, the component source itself, and the test file to migrate.
const prompt = [
'Convert this Enzyme test to React Testing Library:',
`SIBLING TESTS:
${siblingTestFilesSourceCode}`,
`RTL EXAMPLES:
${reactTestingLibraryExamples}`,
`IMPORTS:
${nearestImportSourceCode}`,
`COMPONENT SOURCE:
${componentFileSourceCode}`,
`TEST TO MIGRATE:
${testFileSourceCode}`,
].join('
');Providing rich context allowed the LLM to understand team‑specific patterns and the overall codebase architecture, which was crucial for handling complex files.
Results and Impact
With the validation pipeline, retry loops, and expanded prompts, the team migrated 75% of target files within four hours of the first bulk run. After four days of a "sample‑tune‑sweep" feedback loop, the success rate rose to 97%, leaving fewer than 100 files. Those remaining files required 50–100 retries each and were finally fixed manually, using the automated output as a baseline.
The migration preserved original test intent and overall code coverage. Total cost—including LLM API usage and six weeks of engineering time—was far lower than the original estimate of 1.5 years of manual work.
Next Steps
Airbnb plans to extend this approach, building more advanced migration tools and exploring further LLM‑driven automation to boost developer productivity.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Airbnb Technology Team
Official account of the Airbnb Technology Team, sharing Airbnb's tech innovations and real-world implementations, building a world where home is everywhere through technology.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
