-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Add Miniflare/startWorker() + node:test
tutorial
#19254
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
Deploying cloudflare-docs with
|
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 |
node:test
tutorialnode:test
tutorial
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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
Preview URL: https://3a175b86.preview.developers.cloudflare.com Files with changes (up to 15)
|
Co-authored-by: ToriLindsay <tgalatro@cloudflare.com>
Summary
This PR adds a tutorial for how to test using Miniflare &
node:test
. Still to come, a tutorial for how to test usingstartWorker()
andnode:test
.Documentation checklist