-
Notifications
You must be signed in to change notification settings - Fork 10.1k
[workers] restructure workers testing docs #21127
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
Conversation
|
This PR changes current filenames or deletes current files. Make sure you have redirects set up to cover the following paths:
|
|
|
||
| - `miniflare`: `SourcelessWorkerOptions & { workers?: WorkerOptions\[]; }` optional | ||
|
|
||
| - Use this to provide configuration information that is typically stored within the [Wrangler configuration file](/workers/wrangler/configuration/), such as [bindings](/workers/runtime-apis/bindings/), [compatibility dates](/workers/configuration/compatibility-dates/), and [compatibility flags](/workers/configuration/compatibility-flags/). The `WorkerOptions` interface is defined [here](https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare#interface-workeroptions). Use the `main` option above to configure the entry point, instead of the Miniflare `script`, `scriptPath`, or `modules` options. |
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.
Identified issues
- Vale Style Guide - (cloudflare.MeaningfulLinkWords-warning) Warning: Rewrite the link text for
[here](https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare#interface-workeroptions)to be more descriptive. For more information, refer to Descriptive link text.
Proposed fix
| - Use this to provide configuration information that is typically stored within the [Wrangler configuration file](/workers/wrangler/configuration/), such as [bindings](/workers/runtime-apis/bindings/), [compatibility dates](/workers/configuration/compatibility-dates/), and [compatibility flags](/workers/configuration/compatibility-flags/). The `WorkerOptions` interface is defined [here](https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare#interface-workeroptions). Use the `main` option above to configure the entry point, instead of the Miniflare `script`, `scriptPath`, or `modules` options. | |
| The `WorkerOptions` interface is defined in the [Miniflare documentation](https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare#interface-workeroptions). |
The link text 'here' is not descriptive. I've changed it to 'in the Miniflare documentation' to provide more context about the link's destination.
| The Workers Vitest integration is the recommended way to test Workers and [Pages Functions](/pages/functions/). | ||
|
|
||
| [Vitest](https://vitest.dev/) is a popular JavaScript testing framework featuring a very fast watch mode, Jest compatibility, and out-of-the-box support for TypeScript. | ||
| The `@cloudflare/vitest-pool-workers` package works by running code inside a Cloudflare Worker where Vitest would usually run inside a [Node.js worker thread](https://nodejs.org/api/worker_threads.html). |
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.
Identified issues
- Vale Style Guide - (Terms-error) Use 'Cloudflare' instead of 'cloudflare'.
- Vale Style Guide - (Terms-error) Use 'Workers' instead of 'workers'.
Proposed fix
| The `@cloudflare/vitest-pool-workers` package works by running code inside a Cloudflare Worker where Vitest would usually run inside a [Node.js worker thread](https://nodejs.org/api/worker_threads.html). | |
| The `@cloudflare/vitest-pool-workers` package works by running code inside a Cloudflare Worker where Vitest would usually run inside a [Node.js Worker thread](https://nodejs.org/api/worker_threads.html). |
I capitalized 'Cloudflare' and 'Workers' as per the style guide recommendation. The term 'cloudflare' within the package name is a code reference and should not be changed.
|
|
||
| For example, to add bindings that will be used in tests, you can add `miniflare` to `defineWorkersConfig`: | ||
| For example, this configuration would add a KV namespace `TEST_NAMESPACE` that was only accessible in tests. Using this method, you can add or override existing bindings like Durable Objects or service bindings. | ||
| // maybe mention mocking things (e.g. as a service binding) and link to a separate page. |
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.
Identified issues
- Vale Style Guide - (cloudflare.LatinTerms-warning) Use 'for example' instead of 'e.g.', but consider rewriting the sentence.
Proposed fix
| // maybe mention mocking things (e.g. as a service binding) and link to a separate page. | |
| // maybe mention mocking things (for example, as a service binding) and link to a separate page. |
I replaced 'e.g.' with 'for example' to comply with the style guide. This change does not affect any code references or restricted areas.
|
Howdy and thanks for contributing to our repo. The Cloudflare team reviews new, external PRs within two (2) weeks. If it's been two weeks or longer without any movement, please tag the PR Assignees in a comment. We review internal PRs within 1 week. If it's something urgent or has been sitting without a comment, start a thread in the Developer Docs space internally. PR Change SummaryRestructured the Workers testing documentation to enhance clarity and accessibility, emphasizing the Vitest integration and updating outdated information.
Modified Files
Added Files
Renamed Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add What is Hyperlint?Hyperlint is an AI agent that helps you write, edit, and maintain your documentation. Learn more about the Hyperlint AI reviewer and the checks that we can run on your documentation. |
|
CI run failed: build logs |
Summary
This is a WIP! Opening this in a very rough state to start discussion on structure, and any feedback is welcome 🧡
The testing docs were quite nested before - this PR aims to restructure pages so that the Vitest integration is more prominent, and you get to writing your first test sooner.
Also updates some out of date information along the way.
main structural changes
Screenshots (optional)
Documentation checklist