Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to migrate Jest unit tests to Miniflare V3? #747

Closed
nvie opened this issue Dec 8, 2023 · 1 comment
Closed

How to migrate Jest unit tests to Miniflare V3? #747

nvie opened this issue Dec 8, 2023 · 1 comment

Comments

@nvie
Copy link

nvie commented Dec 8, 2023

We recently started using the Message.ack() and Message.retry() methods, to explicitly acknowledge processed messages, but when running our local Miniflare tests, we noticed these errors:

TypeError: n.ack is not a function
  at Object.Sw [as queue] (src/queues.ts:134:15)
  at async Promise.all (index 0)
  at ServiceWorkerGlobalScope.[kDispatchQueue] (node_modules/@miniflare/core/src/standards/event.ts:460:13)
  at Object.queueEventDispatcher [as dispatcher] (node_modules/@miniflare/core/src/index.ts:421:7)
  at WorkerQueue.#flush (node_modules/@miniflare/queues/src/broker.ts:217:7)

We thought we were using [email protected] (because it's in our devDependencies), but upon closer inspection it turned out we're also using [email protected] in there, and so it looks like we're actually still working with Miniflare V2 in Jest. We really want to upgrade to Miniflare V3, but it's unclear how to set this up and migrate our existing (and extensive) Jest test suite.

What's the replacement for jest-environment-miniflare that works with Miniflare V3 / workerd setups?

This page also didn't help much. Could you provide any guidance?

@mrbbot
Copy link
Contributor

mrbbot commented Dec 8, 2023

Hey! 👋 We're actively working on bringing Miniflare 2's unit testing environments to Miniflare 3 (https://github.com/cloudflare/workers-sdk/tree/bcoll/vitest-pool-workers/packages/vitest-pool-workers). We're not quite ready for release yet but getting there. 🙂 Hoping to do an initial pre-release in the next few weeks, or early next year. We're only planning to support Vitest initially though. I'd encourage you to consider migrating (https://vitest.dev/guide/migration.html#migrating-from-jest) when we release this, as Vitest provides better support for TypeScript and ES modules out-of-the-box. I'm going to close this in favour of this tracking issue: cloudflare/workers-sdk#4490.

@mrbbot mrbbot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants