Known issues
The Workers Vitest pool is currently in open-beta. These are issues Cloudflare is aware of and fixing:
- Dynamic
import()
statements do not work insideexport default { ... }
handlers when writing integration tests withSELF
, or inside Durable Object event handlers. You must use staticimport
statements in the global scope. console.log()
s insideexport default { ... }
handlers are not shown when writing integration tests withSELF
if the handler does no asynchronous work. You can work around this by includingctx.waitUntil(scheduler.wait(100))
in your tests during debugging to keep the request context alive for long enough.- If you are writing integration tests with
SELF
, you must import your Worker’smain
entrypoint in your test file for tests to re-run when files change. For example, ifmain
was set to./src/index.ts
, includeimport "./src/index"
at the top of each test file. Vite’s module analysis that powers hot-module-reloading is performed statically and currently does not detect the dynamic import ofmain
in our test runner. - Durable Object alarms are not reset between test runs and do not respect isolated storage. Ensure you delete or run all alarms scheduled in each test before finishing the test.