Skip to content

Commit

Permalink
docs: add better console messaging for remote development
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjessop committed Feb 4, 2025
1 parent 6a3436d commit 22145c1
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-taxis-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

docs: clarifies that local resources are "simulated locally" or "connected to remote resource", and adds console messages to help explain local dev
2 changes: 2 additions & 0 deletions packages/wrangler/e2e/dev-with-resources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ describe.sequential.each(RUNTIMES)("Bindings: $flags", ({ runtime, flags }) => {
const worker = helper.runLongLived(
`wrangler dev ${flags} --port ${port} --inspector-port ${inspectorPort} --experimental-vectorize-bind-to-prod`
);
const matches = await worker.readUntil(/connected to remote resource/);
expect(matches.length).toEqual(1);
const { url } = await worker.waitForReady();
const res = await fetch(url);

Expand Down
8 changes: 4 additions & 4 deletions packages/wrangler/e2e/pages-dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ describe.sequential.each([{ cmd: "wrangler pages dev" }])(
expect(normalizeOutput(worker.currentOutput)).toContain(
dedent`Your worker has access to the following bindings:
- Durable Objects:
- TEST_DO: TestDurableObject (defined in a [not connected]) (local)
- TEST_DO: TestDurableObject (defined in a [not connected])
- KV Namespaces:
- TEST_KV: TEST_KV (local)
- TEST_KV: TEST_KV [simulated locally]
- D1 Databases:
- TEST_D1: local-TEST_D1 (TEST_D1) (local)
- TEST_D1: local-TEST_D1 (TEST_D1) [simulated locally]
- R2 Buckets:
- TEST_R2: TEST_R2 (local)
- TEST_R2: TEST_R2 [simulated locally]
- Services:
- TEST_SERVICE: test-worker [not connected]
`
Expand Down
44 changes: 37 additions & 7 deletions packages/wrangler/src/__tests__/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1206,12 +1206,17 @@ describe.sequential("wrangler dev", () => {
process.platform === "win32" ? "127.0.0.1" : "localhost"
);
expect(std.out).toMatchInlineSnapshot(`
"Your worker has access to the following bindings:
"Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
Your worker has access to the following bindings:
- Durable Objects:
- NAME_1: CLASS_1 (local)
- NAME_2: CLASS_2 (defined in SCRIPT_A [not connected]) (local)
- NAME_3: CLASS_3 (local)
- NAME_4: CLASS_4 (defined in SCRIPT_B [not connected]) (local)
- NAME_1: CLASS_1 [simulated locally]
- NAME_2: CLASS_2 (defined in SCRIPT_A [not connected])
- NAME_3: CLASS_3 [simulated locally]
- NAME_4: CLASS_4 (defined in SCRIPT_B [not connected])
Use \\"wrangler dev --remote\\" to run both your Worker and all bindings remotely (https://developers.cloudflare.com/workers/testing/local-development/#develop-using-remote-resources-and-bindings).
"
`);
expect(std.warn).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -1297,6 +1302,8 @@ describe.sequential("wrangler dev", () => {
});
expect(std.out).toMatchInlineSnapshot(`
"Using vars defined in .dev.vars
Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
Your worker has access to the following bindings:
- Vars:
- VAR_1: \\"(hidden)\\"
Expand All @@ -1306,6 +1313,9 @@ describe.sequential("wrangler dev", () => {
- VAR_MULTI_LINE_2: \\"(hidden)\\"
- EMPTY: \\"(hidden)\\"
- UNQUOTED: \\"(hidden)\\"
Use \\"wrangler dev --remote\\" to run both your Worker and all bindings remotely (https://developers.cloudflare.com/workers/testing/local-development/#develop-using-remote-resources-and-bindings).
"
`);
});
Expand All @@ -1331,9 +1341,14 @@ describe.sequential("wrangler dev", () => {
expect(varBindings).toEqual({ CUSTOM_VAR: "custom" });
expect(std.out).toMatchInlineSnapshot(`
"Using vars defined in .dev.vars.custom
Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
Your worker has access to the following bindings:
- Vars:
- CUSTOM_VAR: \\"(hidden)\\"
Use \\"wrangler dev --remote\\" to run both your Worker and all bindings remotely (https://developers.cloudflare.com/workers/testing/local-development/#develop-using-remote-resources-and-bindings).
"
`);
});
Expand Down Expand Up @@ -1850,10 +1865,15 @@ describe.sequential("wrangler dev", () => {
fs.writeFileSync("index.js", `export default {};`);
await runWranglerUntilConfig("dev index.js");
expect(std.out).toMatchInlineSnapshot(`
"Your worker has access to the following bindings:
"Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
Your worker has access to the following bindings:
- Services:
- WorkerA: A [not connected]
- WorkerB: B [not connected]
Use \\"wrangler dev --remote\\" to run both your Worker and all bindings remotely (https://developers.cloudflare.com/workers/testing/local-development/#develop-using-remote-resources-and-bindings).
"
`);
expect(std.warn).toMatchInlineSnapshot(`""`);
Expand All @@ -1871,10 +1891,15 @@ describe.sequential("wrangler dev", () => {
fs.writeFileSync("index.js", `export default {};`);
await runWranglerUntilConfig("dev index.js");
expect(std.out).toMatchInlineSnapshot(`
"Your worker has access to the following bindings:
"Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
Your worker has access to the following bindings:
- Services:
- WorkerA: A [not connected]
- WorkerB: B [not connected]
Use \\"wrangler dev --remote\\" to run both your Worker and all bindings remotely (https://developers.cloudflare.com/workers/testing/local-development/#develop-using-remote-resources-and-bindings).
"
`);
expect(std.warn).toMatchInlineSnapshot(`""`);
Expand All @@ -1898,11 +1923,16 @@ describe.sequential("wrangler dev", () => {
await runWranglerUntilConfig("dev index.js");
expect(std.out).toMatchInlineSnapshot(`
"Using vars defined in .dev.vars
Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
Your worker has access to the following bindings:
- Vars:
- variable: 123
- overriden: \\"(hidden)\\"
- SECRET: \\"(hidden)\\"
Use \\"wrangler dev --remote\\" to run both your Worker and all bindings remotely (https://developers.cloudflare.com/workers/testing/local-development/#develop-using-remote-resources-and-bindings).
"
`);
});
Expand Down
Loading

0 comments on commit 22145c1

Please sign in to comment.