Using vitest without defining `nodejs_compat` for my worker
I am following the instructions here: https://developers.cloudflare.com/workers/testing/vitest-integration/get-started/write-your-first-test/
It says that:
In your project’s wrangler.toml configuration file, […] include nodejs_compat in your compatibility flags.My lib doesn't need that flag so it seems a bit silly just to enable it for tests. Is there a way to run tests without that flag?
8 Replies
No, the vitest integration needs it for running tests
@Walshy | Out of office Thanks. Thinking about it now. I guess I could just point the tests at a different toml file right?
Sure if you wanted
Any reason to not just enable though?
@Walshy | Out of office Not really, it just adds to the weight of the worker when it really isn't needed I guess.
Doesn't need to. If you do
compatibility_flags = ["nodejs_compat", "no_nodejs_compat_v2"]
It'd use node compat v1, only runtime APIs. Nothing extra in the workerruntime APIs also add weight, right? I know we talking about tiny differences here. So it's probably more about my OCD rather than a legitimate concern.
Nah, it's built into the runtime. They just are usable, they don't touch your code at all.
Just like
fetch
and caches
don't add any weight 🙂Cool, I thought they might technically add a bit to the startup time to make them available. Anyway, thank you for your help. 🙏