-
Notifications
You must be signed in to change notification settings - Fork 10.1k
[workers] restructure testing docs #21560
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b6393fd
flatten
emily-shen ccba31a
change integration-testing.mdx to unstable startworker
emily-shen fff4cae
redirects
emily-shen cd99a41
fixup
emily-shen a88ab00
remove duplicated redirect
emily-shen 06c6f67
pr feedback
emily-shen 0fcddf5
fix links
emily-shen 7561d3d
capitalisation
emily-shen dadd35a
more invalid links
emily-shen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 0 additions & 139 deletions
139
src/content/docs/workers/testing/integration-testing.mdx
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| --- | ||
| title: Wrangler's unstable_startWorker() | ||
| pcx_content_type: concept | ||
| sidebar: | ||
| order: 17 | ||
| head: [] | ||
| description: Write integration tests using Wrangler's `unstable_startWorker()` API | ||
| --- | ||
|
|
||
| import { Render } from "~/components"; | ||
| import { LinkButton } from "@astrojs/starlight/components"; | ||
|
|
||
| :::note | ||
| For most users, Cloudflare recommends using the Workers Vitest integration. If you have been using `unstable_dev()`, refer to the [Migrate from `unstable_dev()` guide](/workers/testing/vitest-integration/migration-guides/migrate-from-unstable-dev/). | ||
| ::: | ||
|
|
||
| :::caution | ||
| `unstable_startWorker()` is an experimental API subject to breaking changes. | ||
| ::: | ||
|
|
||
| If you do not want to use Vitest, consider using [Wrangler's `unstable_startWorker()` API](/workers/wrangler/api/#unstable_startworker). This API exposes the internals of Wrangler's dev server, and allows you to customise how it runs. Compared to using [Miniflare directly](/workers/testing/miniflare/writing-tests/) for testing, you can pass in a Wrangler configuration file, and it will automatically load the configuration for you. | ||
emily-shen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| This example uses `node:test`, but should apply to any testing framework: | ||
|
|
||
| ```ts | ||
| import assert from "node:assert"; | ||
| import test, { after, before, describe } from "node:test"; | ||
| import { unstable_startWorker } from "wrangler"; | ||
|
|
||
| describe("worker", () => { | ||
| let worker; | ||
|
|
||
| before(async () => { | ||
| worker = await unstable_startWorker({ config: "wrangler.json" }); | ||
| }); | ||
|
|
||
| test("hello world", async () => { | ||
| assert.strictEqual( | ||
| await (await worker.fetch("http://example.com")).text(), | ||
| "Hello world", | ||
| ); | ||
| }); | ||
|
|
||
| after(async () => { | ||
| await worker.dispose(); | ||
| }); | ||
| }); | ||
|
|
||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.