Picture it: your test suite passes. Then it fails. Then it passes. You changed nothing. You are now a detective in a crime novel where the murderer is a cloud backup service and the victim is a 5-second timeout.

The setup

On this Windows box, node_modules lives inside a OneDrive-synced folder, accessed through a junction. Which means every time a file gets touched — installed, read, glanced at lovingly — OneDrive perks up like a dog hearing a doorbell and decides this is the moment to sync 5,000 files to the cloud.

Now run npx vitest run. Vitest imports a module. The import has a default 5-second timeout. Normally: instant. But if OneDrive is mid-sync, that file read goes on a little field trip — up to the cloud, around the block, maybe stops for coffee — and the import blows past 5 seconds.

Result: a test “fails” not because the code is wrong, but because Microsoft was busy backing up [email protected] at the wrong moment.

The debugging spiral

The worst part of an environmental flake is that it looks like a real bug. You read the failing test. The test is fine. You read the code. The code is fine. You run it again. It passes. You begin to question your career, your education, and the fundamental stability of causality.

The tell: failures cluster around imports and startup, not assertions. The logic never fails — only the getting-the-file-into-memory part fails. When the thing timing out is “loading a module that’s been loaded a thousand times,” suspect the disk, not the code.

The fix (the pragmatic kind)

We didn’t move node_modules off OneDrive (long story, don’t ask). We just stopped pretending the 5-second default made sense in a haunted filesystem:

npx vitest run --testTimeout=20000 --no-file-parallelism
  • --testTimeout=20000 — give the imports room to survive a sync detour.
  • --no-file-parallelism — stop 12 test files from all triggering OneDrive reads simultaneously, which is just inviting the dog to bark at every doorbell at once.

And when iterating, target a subset instead of the whole suite:

npx vitest run tests/billing

The moral

  • Not every red test is a real failure. Some failures are your environment cosplaying as a bug.
  • A symptom that moves around (imports, startup, timeouts) and won’t reproduce reliably is screaming “infrastructure, not logic.”
  • Document the environmental gotchas loudly, so the next person — possibly you, in three weeks, having forgotten everything — doesn’t spend an afternoon blaming their own code for OneDrive’s enthusiasm.

The tests were never flaky. The filesystem was just... very dedicated to its backup responsibilities.


Amit Jethva is the CTO and co-founder of Nuvika Technologies Pvt Ltd, makers of Fintropy, a multi-cloud FinOps platform. Learn more at nuvikatech.com.