You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to enable globalAsyncIO, globalTimers, and globalRandom for workerd in order to use the runtime for executing a tests suite that requires async IO, timers, and random generation outside handlers?
I can find the relevant options in the Miniflare API but I'd prefer to run the tests with workerd directly.
Thanks in advance.
The text was updated successfully, but these errors were encountered:
No, there's no way to support I/O at the global scope. Instead, you will need to arrange for your test suite to be called from a fetch handler, or some other event handler.
Eventually I'd like for us to add some sort of build-in support for running tests. I'd imagine this would be accomplished through something like a "test handler" -- and event handler function which is only called for the purpose of running tests. This would be called with I/O fully enabled, etc.
But, disallowing I/O at the global scope is an important design decision for us, since it guarantees that the global scope is fully deterministic. I don't think we should make an exception for tests, because you probably want your tests to fail if you're doing something at the global scope which won't be allowed in production.
As a point of order, we like our issues to be restricted to specific actionable tasks, so I am going to close this. However, I think there's definitely an important discussion to be had about how to support unit tests in workerd. Please feel free to start a discussion under the discussion tab about this if you feel so inclined.
Hi there,
Is there a way to enable
globalAsyncIO
,globalTimers
, andglobalRandom
for workerd in order to use the runtime for executing a tests suite that requires async IO, timers, and random generation outside handlers?I can find the relevant options in the Miniflare API but I'd prefer to run the tests with workerd directly.
Thanks in advance.
The text was updated successfully, but these errors were encountered: