Skip to content

Conversation

@penalosa
Copy link
Contributor

Summary

This PR adds a tutorial for how to test using Miniflare & node:test. Still to come, a tutorial for how to test using startWorker() and node:test.

Documentation checklist

  • The documentation style guide has been adhered to.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.
  • Files which have changed name or location have been allocated redirects.

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 total issue(s) found.

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 2 total issue(s) found.

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 total issue(s) found.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 16, 2025

Deploying cloudflare-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: bf3abd8
Status: ✅  Deploy successful!
Preview URL: https://e65f1bc6.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://penalosa-improve-testing-doc.cloudflare-docs-7ou.pages.dev

View logs

@penalosa penalosa changed the title Add Miniflare + node:test tutorial Add Miniflare/startWorker() + node:test tutorial Jan 16, 2025
Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
When using the [Vitest integration](/workers/testing/vitest-integration/), your entire test suite runs in [`workerd`](https://github.com/cloudflare/workerd), which is why it's possible to unit test individual functions. By contrast, when using a different testing framework to run tests via Miniflare, only your Worker itself is running in [`workerd`](https://github.com/cloudflare/workerd)—your test files run in Node.js. This means that importing functions from your Worker into your test files might exhibit different behaviour than you'd see at runtime if the functions rely on `workerd`-specific behaviour.
</Details>

## Interacting with Bindings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is already sufficiently obvious, but could be worth noting (somewhere on this page) that all bindings specified in your wrangler config file have to be passed into Miniflare's config options. (And mention that these could be mocked, even if there isn't an example for now - I see you opened an issue to track that for later)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add that in a followup PR

@penalosa penalosa enabled auto-merge (squash) February 12, 2025 20:28
@penalosa penalosa merged commit b9304f7 into production Feb 12, 2025
11 checks passed
@penalosa penalosa deleted the penalosa/improve-testing-docs branch February 12, 2025 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:workers Related to Workers product size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants