Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A flaky test passes and fails on the same code without a relevant change to its inputs or environment. The fix is to find the uncontrolled condition—such as shared state, timing, or an external dependency—and control it. Rerunning can reveal intermittency, but it does not repair the test or prove the product code is sound.

What makes a test flaky?

Martin Fowler describes a nondeterministic test as one that sometimes passes and sometimes fails without a noticeable change in code, tests, or environment. Mike Bland similarly defines flaky tests as producing different results without changes to the code under test or its inputs. The common thread is an uncontrolled dependency that affects the outcome.

A failure is not automatically evidence of flakiness. First check whether the code, inputs, test configuration, or environment changed between runs. An intermittent result is a symptom to investigate, not a reason to dismiss a failure.

How to investigate a flaky test

  1. Record the failure. Capture the test name, assertion or error, commit or revision, environment, test order, and whether that same revision passes on rerun. Compare like with like before calling it flaky.
  2. Run it alone and in its suite. If it fails only in the suite, look for order dependence, shared fixtures, static or global state, database records, incomplete setup, faulty teardown, or collisions during parallel execution. Try a clean starting state where practical.
  3. Make the failure observable. Repeat under controlled seeds and conditions, and capture logs and relevant state. Change one suspected variable at a time; changing several at once can make it harder to identify the cause.
  4. Inspect asynchronous boundaries. Find fixed sleeps and ask whether the test is waiting for the actual condition or merely hoping it has occurred by then.
  5. Check environmental dependencies. Review direct wall-clock reads, remote services and network conditions, browser timing, animation, popup dialogs, pre-existing test data, and managed resources such as database connections.
  6. Repair and validate. Control the source of nondeterminism, then repeat the test in isolation and in the relevant suite—including the conditions that previously triggered failure. Preserve an assertion for the original defect when possible.

For a deeper discussion of isolation and other sources of nondeterminism, see Martin Fowler’s guide to eradicating nondeterminism in tests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Fix the cause, not the symptom

Shared state and test isolation

A test may inherit database rows, mutable static data, singleton state, or other residue from earlier tests. Prefer rebuilding a known starting state when the cost is acceptable. Shared immutable fixtures can be appropriate when setup is expensive, but mutable shared state makes tests harder to reason about. Cleanup can help, yet a cleanup error may make the wrong test appear to fail. Transaction rollback is useful when a test can run without committing.

Also check whether parallel tests write to the same records, files, ports, or other resources. Give tests isolated resources or serialize the conflicting work. Then verify the test both alone and under the suite’s normal execution pattern.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Asynchronous work and timing

A fixed sleep is fragile: a short delay can expire before work finishes on a slower run, while a long delay wastes time on every run. Prefer a callback when the system exposes one. Otherwise, poll for the expected condition with a bounded timeout and a failure message that explains what was still missing. Never wait indefinitely; a timeout should reveal a genuinely missing response.

Time, services, and changing data

Tests that read the wall clock, depend on remote services, or use data that changes outside the test can produce different outcomes without a code change. Where practical, control the clock, use stable test data, or isolate the unstable dependency. Stubbing a third-party service may improve repeatability, but it removes confidence in that real integration boundary; retain another way to verify the behavior beyond the stub.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Browser behavior and end-to-end coverage

Browser timing, animations, dialogs, and other GUI behavior can make end-to-end tests fail intermittently. Keep end-to-end coverage focused on important user journeys, and put detailed business rules in faster, lower-level tests. End-to-end tests still provide integration confidence, so when a boundary is stubbed or excluded, use another verification method for the behavior lost at that boundary. See Fowler’s guidance on the practical test pyramid and testing strategies in a microservice architecture.

Choose a repair that preserves useful coverage

Compare candidate fixes on diagnostic confidence, stability under the known failure conditions, regression coverage retained, suite runtime, maintenance burden, and fidelity to production behavior. For example, a service stub may stabilize a test but reduce integration confidence; a longer sleep may hide a timing issue while increasing runtime and still failing under slower conditions.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Favor the narrowest repair that controls the cause while preserving the assertion that matters. After changing the test or its setup, rerun it under the previously failing conditions and in the suite. A clean run is evidence, not proof that every relevant condition has been covered.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When to quarantine a flaky test

Quarantine can temporarily protect the rest of the suite’s signal while a failure is investigated. But a quarantined test no longer acts as an ordinary regression check. Keep it visible in a separate queue or later pipeline stage, record why it was quarantined, assign an owner, and set a removal deadline. Fowler gives a one-week limit as an example, not a universal standard.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Do not treat repeated reruns, permanently disabling the test, or quarantining it without ownership as a fix. If coverage must be reduced at an unstable boundary, document the gap and retain another verification method for the behavior that boundary was meant to check.

Or skip the browser setup:

If you are debugging a flaky browser test and need a screenshot of a page to inspect its rendered state, ScreenshotNeo offers a one-request screenshot API. Its capture can accept cookie or consent banners and remove known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits cost nothing, with the page verdict and billing status reported in response headers. Its MCP server provides screenshot tools for AI agents, and the free plan includes 1,000 screenshots per month without a card.

Example cURL request (replace the URL with the page you need to inspect):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Free sign-up: get 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Should I rerun a failed test until it passes?

Reruns can help establish that a failure is intermittent, but passing later does not identify or fix its cause. Investigate the conditions that changed.

Is there a universal quarantine deadline for flaky tests?

No. Set a deadline appropriate to the team and keep an owner accountable; a one-week limit is one example, not a standard.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.