இது ஒரு Slack செய்தியுடன் தொடங்குகிறது. பில்ட் (build) சிவப்பு நிறத்தில் உள்ளது. நீங்கள் தோல்விகளைத் தேடிப் பார்த்து, கவலையுடன் உங்கள் லேப்டாப்பில் அதே சோதனையை மீண்டும் செய்கிறீர்கள். அது வெற்றிகரமாக (Green) முடிகிறது. நீங்கள் CI வேலையை மீண்டும் முயற்சிக்கிறீர்கள். ஒருவேளை அது தற்காலிகத் தடையா என்று நினைக்கிறீர்கள். ஆனால் அந்தத் தோல்வி மீண்டும் வருகிறது; சர்வரில் அது பிடிவாதமாகவும் மீண்டும் மீண்டும் நிகழும் விதமாகவும் உள்ளது, ஆனால் உங்களுக்குத் தெரியவில்லை.

CI-இல் தோல்வியடைந்து, உள்ளூர் கணினியில் (locally) வெற்றிகரமாக முடியும் ஒரு பிரவுசர் சோதனை வெறும் எரிச்சலைத் தருவதோடு நின்றுவிடுவதில்லை. அது நம்பிக்கையின்மையைத் தூண்டுகிறது. குழுக்கள் நேரத்தைக் (timing) காரணமாகக் கூறத் தொடங்குகின்றன. அவர்கள் நிரந்தரமற்ற தற்காலிகத் தீர்வுகளைச் சேர்க்கிறார்கள். இங்கே ஒரு setTimeout, அங்கே ஒரு .wait(5000). இதனால் சோதனைத் தொகுப்பு (test suite) மெதுவாகிறது. தோல்விகள் மீண்டும் மீண்டும் வருகின்றன. அந்த நிலையற்ற சோதனைகள் (flaky tests) நிரந்தரமான ஒன்றாக மாறிவிடுகின்றன, இறுதியில் அனைவரும் ஒரு சிவப்பு நிறப் பைப்லைனை (red pipeline) வெறும் பின்னணிச் சத்தமாகவே கருதத் தொடங்குகிறார்கள்.

அது ஆபத்தானது. பொய் சொல்லும் ஓநாயைப் போல (cries wolf) அடிக்கடி எச்சரிக்கும் ஒரு சோதனைத் தொகுப்பை நீங்கள் விரும்ப மாட்டீர்கள்.

CI உடைந்துவிடவில்லை; அது வேறுபட்டது

CI சூழல்கள் (environments) தன்னிச்சையானவை அல்ல. அவை தீர்மானிக்கப்பட்டவை (deterministic). பிரச்சனை என்னவென்றால், அவை உங்கள் MacBook அல்லது Linux workstation அல்லாத ஒரு அமைப்பைப் பொறுத்துத் தீர்மானிக்கப்படுகின்றன. உங்கள் உள்ளூர் அமைப்பு (local setup) மறைத்து வைத்திருக்கும் வேறுபாடுகளை, ஒரு சுத்தமான CI runner உடனடியாக வெளிச்சம் போட்டுக் காட்டும்.

எத்தனை விஷயங்கள் மாறுபடுகின்றன என்று யோசித்துப் பாருங்கள். உங்கள் உள்ளூர் கணினி hot module reloading வசதியுடன் கூடிய ஒரு development server-ஐ இயக்கலாம், ஆனால் CI ஆனது tree shaking மற்றும் minification வசதியுடன் கூடிய ஒரு production artifact-ஐ உருவாக்கும். இதுவே குறியீட்டுப் பாதைகளை (code paths) நீக்கலாம் அல்லது செயல்பாட்டு வரிசையை (execution order) மாற்றலாம். Dependency trees மாறுகின்றன. ஒரு lockfile பார்ப்பதற்கு ஒரே மாதிரியாக இருந்தாலும், package manager பதிப்பு ஒரு சிறிய மாற்றத்தினால் மாறினால், அதன் முடிவுகள் வேறாக இருக்கலாம். நெட்வொர்க் வரிசைகள் மாறுகின்றன. உங்கள் அலுவலக Wi-Fi ஒரு staging API-ஐ எளிதாக அணுகலாம்; ஆனால் CI runner ஒரு load balancer-க்கு பின்னால் உள்ள வேறு ஒரு கிளஸ்டரை (cluster) அணுகக்கூடும், இது நீங்கள் பார்க்க முடியாத தாமதத்தை (latency) ஏற்படுத்தும்.

பிரவுசர்கள் கூட வெவ்வேறு சூழல்களில் வெவ்வேறு விதமாகச் செயல்படுகின்றன. உங்கள் உள்ளூர் Chrome-இல் extensions, சேமிக்கப்பட்ட விவரங்கள் (cached credentials), persistent local storage மற்றும் hardware acceleration வசதியுடன் கூடிய GPU ஆகியவை இருக்கும். ஆனால் CI ஒவ்வொரு முறையும் ஒரு புதிய (blank profile) நிலையில் இருந்து தொடங்கும். Browser lifecycles மாறுபடுகின்றன. Rendering paths மாறுபடுகின்றன. உங்கள் கணினியில் உள்ள எழுத்துருக்கள் (fonts) CI-இல் மாற்றப்படலாம். Viewport அளவு மற்றும் device pixel ratios மாறுபடுகின்றன, இது responsive breakpoints-களை மாற்றலாம் அல்லது lazy-loading செயல்பாட்டைப் பாதிக்கலாம்.

இந்த இடைவெளிகள் உண்மையானவை. இவை இயந்திரவியல் ரீதியானவை. இவை தன்னிச்சையானவை என்று நினைப்பது அவற்றை நீக்கிவிடாது.

Preview சூழல்கள் பொய் சொல்கின்றன

Preview சூழல்கள் இந்தப் பிரச்சனையை இன்னும் சிக்கலாக்குகின்றன. அவை மனித ஆய்வுக்குப் பயனுள்ளவை, ஆனால் அவை production அல்ல. அவை பெரும்பாலும் உண்மையான API host-க்கு பதிலாக api-staging-ஐக் குறிக்கின்றன. Feature flags ஒவ்வொரு சோதனைக்கும் 'true' எனத் தீர்மானிக்கப்படுவதால், production-இல் செயல்படும் நிபந்தனைத் தர்க்கங்கள் (conditional logic) மறைந்துவிடுகின்றன. Authentication ஒரு படிதட்டத் தவிர்க்கலாம் அல்லது ஒரு mock token-ஐப் பயன்படுத்தலாம். Cookies தளர்வான கொள்கைகளைப் பயன்படுத்தலாம். தரவுத்தொகுப்பு (dataset) மிகச் சிறியதாக இருக்கலாம் (பத்தாயிரம் வரிசைகளுக்குப் பதிலாக பத்து வரிசைகள்), இதன் பொருள் pagination, search ranking அல்லது virtualization தர்க்கங்கள் சோதிக்கப்படவே மாட்டாது.

உங்கள் சோதனை ஒரு preview URL-இல் வெற்றி பெற்று, production-இல் தோல்வியடைந்தால் (அல்லது அதற்கு நேர்மாறாக), அந்தச் சோதனைதான் பிழை (bug) அல்ல. அந்தச் சூழல்தான் (environment) பிழை.

யூகிக்கத் தொடங்கும் முன் பதிவு செய்யுங்கள் (Log)

ஒரு தோல்வி முதலில் தோன்றும் போது, சோதனையைச் சற்று மாற்றிவிட்டு அது சரியாகிவிடுமா என்று எதிர்பார்க்கும் உணர்வைத் தவிர்க்கவும். யூகிக்க வேண்டாம். ஒரு வெற்றிகரமான ஓட்டத்தையும் (passing run), தோல்வியடைந்த ஓட்டத்தையும் ஒப்பிட்டுப் பார்க்க, அந்தச் சூழலை (context) அப்படியே உறைய வைக்க (freeze) வேண்டும்.

சந்தேகத்திற்குரிய விஷயங்களைப் பதிவு செய்யுங்கள். தோல்வி ஏற்படும் தருணத்தில் பக்கத்தின் URL, build ID மற்றும் commit SHA ஆகியவற்றைத் பதிவு செய்யவும். செயல்படும் feature flags-களைக் குறித்துக் கொள்ளவும். API host, துல்லியமான browser version மற்றும் viewport அளவு ஆகியவற்றைச் சேகரிக்கவும். இந்த விவரங்கள் ஒரு மர்மமான தோல்வியை மீண்டும் உருவாக்கக்கூடிய (reproducible) ஒரு நிலையாக மாற்றும்.

ஸ்கிரீன்ஷாட்டுகளை (screenshots) மட்டுமே நம்பியிருக்க வேண்டாம். இரண்டு பக்கங்கள் பார்ப்பதற்கு ஒரே மாதிரியாக இருக்கலாம், ஆனால் அவை முற்றிலும் மாறுபட்ட JavaScript-ஐ இயக்கலாம். CI bundle-இல் ஒரு கூடுதல் polyfill சேர்க்கப்பட்டதோ அல்லது உங்கள் browser cache-இல் ஏற்கனவே இருந்ததால் local bundle ஒரு பகுதியைத் தவிர்த்ததோ என்பதை ஒரு ஸ்கிரீன்ஷாட் உங்களுக்குச் சொல்லாது.

மேலும், DevTools-ஐத் திறப்பது நேரத்தை (timing) மாற்றும் என்பதையும் நினைவில் கொள்ளுங்கள். DevTools garbage collection-ஐத் தள்ளிப்போடலாம், network prioritization-ஐ மாற்றலாம் மற்றும் சில rendering optimizations-களை முடக்கலாம். நீங்கள் DOM-ஐ ஆய்வு செய்யும் போது வெற்றி பெறும் ஒரு சோதனை, அந்தப் பேனலை மூடிவிட்டு headless முறையில் இயக்கும்போது தோல்வியடையலாம். Debugger ஒரு பயனுள்ள கருவிதான், ஆனால் அது நடுநிலையான பார்வையாளர் அல்ல.

குற்றச் சம்பவ இடத்தைப் போல மீண்டும் உருவாக்குங்கள்

நீங்கள் தோல்வியை துல்லியமாக மீண்டும் உருவாக்க விரும்பினால், உங்கள் உள்ளூர் development server-ஐ மட்டும் இயக்கிவிட்டுப் பிரார்த்தனை செய்து கொண்டிருக்க முடியாது. நீங்கள் CI-இன் துல்லியமான சூழலை அப்படியே பிரதிபலிக்க வேண்டும்.

Build the exact artifact that CI produced. Download it if you must. Serve that artifact locally with a simple static file server, not with Vite or Webpack dev middleware. Use the same environment variables that CI injected. Match the browser version precisely. Run it in the same mode, headed or headless, because focus events, media queries, and autoplay policies still diverge between the two in subtle ways. If your CI uses a Docker container, run the same image locally. Remove your personal browser profile entirely.

When the local reproduction finally fails, you have a real debugging session. Until then, you are chasing shadows.

Stop Sleeping, Start Waiting

The most common response to a flaky browser test is to add delay. Wait five seconds. Wait ten. This is not a fix. It is a surrender. Arbitrary delays slow your suite, create false confidence, and still fail under load when the network hiccups.

Instead, wait for evidence of state. If a notification should appear after a form submission, do not wait for time to pass. Wait for a specific notification ID to exist in the DOM. If a counter should increment, wait for the text to change values. If a loading state blocks interaction, wait for the loading marker to disappear. If you are working with a WebSocket or server-sent events, wait for the network stream to produce a specific event.

Explicit waits turn your test from a guessing game into a contract. The test says: "I will proceed once the application confirms it is ready." That is far stronger than saying, "I will proceed once enough seconds have passed."

Hydration and the Disappearing Button

In modern React applications, hydration causes a specific class of failures that local dev servers often mask. The server sends HTML. React boots up in the browser and attaches event listeners. During that window, your test might click a button. React then replaces or restructures that DOM node during hydration. The element handle your test framework was holding now points to a detached node, and you get an error about interacting with a removed element.

The fix is not to write a more complex selector that digs deeper into the component tree. The fix is to look for readiness signals. Wait until a root element gains a hydrated attribute or a known data property. Wait for a skeleton loader to disappear. Wait for a client-side event handler to become active. Let the application announce that it is stable before you fire clicks.

Hidden Culprits: Dependencies and Third-Party Scripts

Sometimes the environment changes even though your application code did not. A transitive update in a small utility library, three levels deep in your node_modules, can alter browser behavior. It might change how promises resolve, how styles get injected, or how mocks intercept requests. When tests begin failing after a routine dependency update, record your package manager version and the lockfile checksum. You need to know whether you are looking at the same tree you were last week.

Third-party scripts are another frequent saboteur. Analytics trackers, payment SDKs, and chat widgets load asynchronously. They inject iframes, shift layout, or steal focus at moments your test does not expect. In CI, these scripts might load more slowly, or they might fail to load entirely because of network restrictions, causing your application to follow a different error-handling path. Log which third-party resources loaded and their HTTP status. If a payment iframe takes three seconds to mount in CI but loads instantly on your fast local connection, your "element not clickable" error suddenly has a clear cause.

And "element not clickable" is never a diagnosis. It is a symptom. Treat the cause.

Build an Evidence Kit

Every CI failure should be actionable. A stack trace alone is not enough. You need an evidence kit that lets another engineer, or yourself next month, reconstruct what happened.

Keep screenshots and video recordings from the failing run. Capture the full browser console output, not just errors but warnings too. Log network failures, including 404s, CORS rejections, and dropped connections. Preserve the build IDs and feature flags that were active. Take a DOM snapshot at the exact moment the assertion failed. A snapshot lets you inspect the HTML structure after the fact, rather