fix-flaky-tests
Fungsinya
Skill ini menyelidiki tes otomatis yang tidak stabil, yaitu tes yang lulus dan gagal tanpa perubahan kode, lalu memperbaikinya. Skill ini untuk pengembang yang menginginkan rangkaian tes yang andal.
Kapan dipakai
- βSaat sebuah tes ditandai tidak stabil di Tuist dan Anda ingin memperbaikinya.
- βSaat banyak tes gagal secara acak dan Anda ingin menemukan penyebab bersamanya.
- βSaat Anda ingin menemukan dan memperbaiki semua tes tidak stabil dalam sebuah proyek.
Link skill
https://github.com/tuist/tuist/blob/main/skills/skills/fix-flaky-tests/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βCari tes tidak stabil di proyek saya dan perbaiki yang paling sering gagal.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent membaca keandalan dan detail kegagalan setiap tes, membuka kode sumbernya di baris yang dilaporkan, mengidentifikasi pola yang menyebabkan ketidakstabilan, memperbaikinya, lalu menjalankan tes beberapa kali untuk memastikan.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Fix Flaky Tests
Quick Start
You'll typically receive a Tuist test case URL or identifier. Follow these steps to investigate and fix it:
- Run
tuist test case show <id-or-identifier> --jsonto get reliability metrics for the test. - Run
tuist test case run list Module/Suite/TestCase --flaky --jsonto see flaky run patterns. - Run
tuist test case run show <test-case-run-id> --jsonon failing flaky runs to get failure messages and file paths. - Read the test source at the reported path and line, identify the flaky pattern, and fix it.
- Verify by running the test multiple times to confirm it passes consistently.
If no specific test is provided, start with the Discovery section below.
Discovery
When no specific test case is provided, find all flaky tests in the project:
tuist test case list --flaky --json --page-size 50
This returns all test cases currently flagged as flaky. Key fields:
module.name/suite.name/nameβ the test identifieravg_durationβ helps prioritize (fix fast unit tests first)is_quarantinedβ whether the test is already quarantined
Triage strategy:
- Group tests by suite β multiple flaky tests in the same suite often share a root cause.
- Check if failures share a
test_run_idβ tests that all failed in the same run may have been killed by a process crash, not individual test bugs. - Look at failure messages to categorize: test logic bugs vs infrastructure issues (network errors, server 502s, conflicts on retry).
Investigation
1. Get test case metrics
You can pass either the UUID or the Module/Suite/TestCase identifier:
tuist test case show <id> --json
tuist test case show Module/Suite/TestCase --json
Key fields:
reliability_rateβ percentage of successful runs (higher is better)flakiness_rateβ percentage of runs marked flaky in the last 30 daystotal_runs/failed_runsβ volume contextlast_statusβ current state
2. View flaky run history
tuist test case run list Module/Suite/TestCase --flaky --json
The identifier uses the format ModuleName/SuiteName/TestCaseName or ModuleName/TestCaseName when there is no suite. This returns only runs that were detected as flaky.
3. View full run history
tuist test case run list Module/Suite/TestCase --json --page-size 20
Look for patterns:
- Does it fail on specific branches?
- Does it fail only on CI (
is_ci: true) or also locally? - Are failures clustered around specific commits?
4. Get failure details
tuist test case run show <test-case-run-id> --json
Key fields:
failures[].messageβ the assertion or error messagefailures[].pathβ source file pathfailures[].line_numberβ exact line of failurefailures[].issue_typeβ type of issue (assertion_failure, etc.)repetitionsβ if present, shows retry behavior (pass/fail sequence)test_run_idβ the broader test run this execution belongs tocrash_reportβ crash report data (present when the test runner crashed); containsexception_type,signal,exception_subtype, andtriggered_thread_frames
Code Analysis
- Open the file at
failures[0].pathand go tofailures[0].line_number. - Read the full test function and its setup/teardown.
- Identify which of the common flaky patterns below applies.
- Check if the test shares state with other tests in the same suite.
Common Flaky Patterns
Timing and async issues
- Missing waits: Test checks a result before an async operation completes. Fix: use
await, expectations with timeouts, or polling. - Race conditions: Multiple concurrent operations access shared state. Fix: synchronize access or use serial queues.
- Hardcoded timeouts:
sleep(1)or fixed delays that are too short on CI. Fix: use condition-based waits instead of fixed delays.
Shared state
- Test pollution: One test modifies global/static state that another test depends on. Fix: reset state in setUp/tearDown or use unique instances per test.
- Singleton contamination: Shared singletons carry state between tests. Fix: inject dependencies or reset singletons.
- File system leftovers: Tests leave files that affect subsequent runs. Fix: use temporary directories and clean up.
Environment dependencies
- Network calls: Tests hit real services that may be slow or unavailable. Fix: mock network calls.
- Date/time sensitivity: Tests depend on current time or tim
Pertanyaan umum
Bagaimana skill menemukan tes tidak stabil?
Skill mendaftar tes yang ditandai tidak stabil dalam insight tes Tuist.
Bagaimana jika tidak ada tes yang diberikan?
Skill menemukan tes tidak stabil di proyek dan mengelompokkannya berdasarkan suite.
Bagaimana perbaikan dikonfirmasi?
Skill menjalankan tes beberapa kali untuk memastikan tes lulus secara konsisten.
Detail
Deskripsi asli dari pembuat
Fixes flaky tests by analyzing failure patterns from Tuist test insights, identifying root causes, and applying targeted corrections. Can be invoked with a specific test case URL (e.g. `https://tuist.dev/{account}/{project}/tests/test-cases/{id}`) or without arguments to discover and fix all flaky tests in the project.
repo: tuist/tuist
Popularitas
- Bintang GitHub
- 5.9k
- Peringkat
- #14544
- Lisensi
- β
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
analyze-selective-testing
5.9kMembantu agent Anda memeriksa seberapa baik selective testing Xcode melewati target tes yang tidak berubah, dan mencari tahu mengapa pelewatan berubah antar-run.
compare-builds
5.9kMembantu agent Anda membandingkan dua run build Xcode untuk menemukan build yang lebih lambat, perubahan penggunaan cache, dan masalah baru.
compare-bundles
5.9kMembantu agent Anda membandingkan dua bundle aplikasi untuk menemukan perubahan ukuran, file yang ditambahkan atau dihapus, dan perbedaan antar platform.
compare-cache-runs
5.9kMembantu agent Anda membandingkan dua run cache untuk menemukan perubahan tingkat cache hit dan menjelaskan mengapa cache dibatalkan.
Skill serupa
test-driven-development
311kMengajari agent Anda menulis tes yang gagal dulu, melihatnya gagal, lalu menulis kode terkecil yang lulus, sebelum membangun fitur atau perbaikan apa pun.
verification-before-completion
311kMengajari agent Anda menjalankan pemeriksaan nyata dan membaca keluarannya sebelum menyatakan tugas, perbaikan, atau build sudah selesai atau lulus.
migrate-to-shoehorn
310kMengganti type cast berisiko di file tes Anda dengan pustaka shoehorn, sehingga tes bisa memakai data parsial dan tetap lulus pemeriksaan tipe.