Cloudflare DevelopersCD
Cloudflare Developersโ€ข3y agoโ€ข
8 replies
vas

๐Ÿ”Œ Multiple Workers ยท Miniflare

Hi, I have a main worker which has service bindings to two other workers. I would like to create jest integration test for the main worker. I have the directory structure similar to the one in https://miniflare.dev/core/mount and the main worker wrangler.toml has [miniflare.mounts] [build.upload]. I am creating a miniflare instance in the jest test file with a script path

describe('bluegreen routing', () => { const mf = new Miniflare({ envPath: true, packagePath: true, wranglerConfigPath: true, scriptPath: 'dist/index.mjs', modules: true }) it('should route to the green worker', async () => { const response = await mf.dispatchFetch('http://127.0.0.1/parent', { method: 'GET' }) if (response) { const parsedResp = await response.text() expect(parsedResp).toEqual('Green Hello World!') } }) })

This test exceeds the timeout. I get this error
ReferenceError: clearImmediate is not defined
Is this the right way to do jest tests with Miniflare?
Fun, full-featured, fully-local simulator for Cloudflare Workers
๐Ÿ”Œ Multiple Workers ยท Miniflare
Was this page helpful?