wrangler 0.0.0-e61fba8 → 0.0.0-e62b097bb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +42 -36
  2. package/bin/wrangler.js +86 -67
  3. package/config-schema.json +3370 -0
  4. package/package.json +132 -103
  5. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  6. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  7. package/templates/__tests__/tsconfig.json +8 -0
  8. package/templates/checked-fetch.js +30 -0
  9. package/templates/facade.d.ts +19 -0
  10. package/templates/gitignore +2 -3
  11. package/templates/init-tests/test-jest-new-worker.js +23 -0
  12. package/templates/init-tests/test-vitest-new-worker.js +24 -0
  13. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  14. package/templates/middleware/common.ts +67 -0
  15. package/templates/middleware/loader-modules.ts +134 -0
  16. package/templates/middleware/loader-sw.ts +229 -0
  17. package/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
  18. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  19. package/templates/middleware/middleware-mock-analytics-engine.d.ts +3 -0
  20. package/templates/middleware/middleware-mock-analytics-engine.ts +30 -0
  21. package/templates/middleware/middleware-patch-console-prefix.d.ts +3 -0
  22. package/templates/middleware/middleware-patch-console-prefix.ts +21 -0
  23. package/templates/middleware/middleware-pretty-error.ts +40 -0
  24. package/templates/middleware/middleware-scheduled.ts +29 -0
  25. package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
  26. package/templates/middleware/middleware-serve-static-assets.ts +56 -0
  27. package/templates/modules-watch-stub.js +4 -0
  28. package/templates/new-worker-scheduled.js +3 -3
  29. package/templates/new-worker-scheduled.ts +16 -16
  30. package/templates/new-worker.js +3 -3
  31. package/templates/new-worker.ts +19 -16
  32. package/templates/no-op-worker.js +10 -0
  33. package/templates/pages-dev-pipeline.ts +32 -0
  34. package/templates/pages-dev-util.ts +55 -0
  35. package/templates/pages-shim.ts +9 -0
  36. package/templates/pages-template-plugin.ts +190 -0
  37. package/templates/pages-template-worker.ts +198 -0
  38. package/templates/startDevWorker/InspectorProxyWorker.ts +664 -0
  39. package/templates/startDevWorker/ProxyWorker.ts +336 -0
  40. package/templates/tsconfig-sanity.ts +11 -0
  41. package/templates/tsconfig.init.json +22 -0
  42. package/templates/tsconfig.json +6 -103
  43. package/wrangler-dist/InspectorProxyWorker.js +464 -0
  44. package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
  45. package/wrangler-dist/ProxyWorker.js +241 -0
  46. package/wrangler-dist/ProxyWorker.js.map +6 -0
  47. package/wrangler-dist/cli.d.ts +26730 -0
  48. package/wrangler-dist/cli.js +165991 -119517
  49. package/Cloudflare_CA.pem +0 -18
  50. package/import_meta_url.js +0 -3
  51. package/miniflare-config-stubs/.env.empty +0 -0
  52. package/miniflare-config-stubs/package.empty.json +0 -1
  53. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  54. package/miniflare-dist/index.mjs +0 -4886
  55. package/pages/functions/buildPlugin.ts +0 -105
  56. package/pages/functions/buildWorker.ts +0 -151
  57. package/pages/functions/filepath-routing.test.ts +0 -234
  58. package/pages/functions/filepath-routing.ts +0 -189
  59. package/pages/functions/identifiers.ts +0 -78
  60. package/pages/functions/routes.ts +0 -156
  61. package/pages/functions/template-plugin.ts +0 -147
  62. package/pages/functions/template-worker.ts +0 -143
  63. package/src/__tests__/config-cache.test.ts +0 -36
  64. package/src/__tests__/configuration.test.ts +0 -3487
  65. package/src/__tests__/dev.test.tsx +0 -1010
  66. package/src/__tests__/guess-worker-format.test.ts +0 -85
  67. package/src/__tests__/helpers/clipboardy-mock.js +0 -4
  68. package/src/__tests__/helpers/cmd-shim.d.ts +0 -11
  69. package/src/__tests__/helpers/faye-websocket.d.ts +0 -6
  70. package/src/__tests__/helpers/mock-account-id.ts +0 -48
  71. package/src/__tests__/helpers/mock-bin.ts +0 -36
  72. package/src/__tests__/helpers/mock-cfetch.ts +0 -211
  73. package/src/__tests__/helpers/mock-console.ts +0 -87
  74. package/src/__tests__/helpers/mock-dialogs.ts +0 -130
  75. package/src/__tests__/helpers/mock-http-server.ts +0 -46
  76. package/src/__tests__/helpers/mock-istty.ts +0 -27
  77. package/src/__tests__/helpers/mock-kv.ts +0 -33
  78. package/src/__tests__/helpers/mock-oauth-flow.ts +0 -255
  79. package/src/__tests__/helpers/mock-stdin.ts +0 -103
  80. package/src/__tests__/helpers/mock-web-socket.ts +0 -29
  81. package/src/__tests__/helpers/run-in-tmp.ts +0 -39
  82. package/src/__tests__/helpers/run-wrangler.ts +0 -16
  83. package/src/__tests__/helpers/write-worker-source.ts +0 -31
  84. package/src/__tests__/helpers/write-wrangler-toml.ts +0 -17
  85. package/src/__tests__/https-options.test.ts +0 -130
  86. package/src/__tests__/index.test.ts +0 -257
  87. package/src/__tests__/init.test.ts +0 -1637
  88. package/src/__tests__/jest.setup.ts +0 -77
  89. package/src/__tests__/kv.test.ts +0 -1502
  90. package/src/__tests__/logger.test.ts +0 -115
  91. package/src/__tests__/package-manager.test.ts +0 -353
  92. package/src/__tests__/pages.test.ts +0 -754
  93. package/src/__tests__/parse.test.ts +0 -330
  94. package/src/__tests__/publish.test.ts +0 -5820
  95. package/src/__tests__/r2.test.ts +0 -233
  96. package/src/__tests__/route.test.ts +0 -45
  97. package/src/__tests__/secret.test.ts +0 -481
  98. package/src/__tests__/tail.test.ts +0 -690
  99. package/src/__tests__/user.test.ts +0 -131
  100. package/src/__tests__/whoami.test.tsx +0 -139
  101. package/src/abort.d.ts +0 -3
  102. package/src/bundle.ts +0 -204
  103. package/src/cfetch/index.ts +0 -121
  104. package/src/cfetch/internal.ts +0 -142
  105. package/src/cli.ts +0 -13
  106. package/src/config/README.md +0 -107
  107. package/src/config/config.ts +0 -234
  108. package/src/config/diagnostics.ts +0 -80
  109. package/src/config/environment.ts +0 -420
  110. package/src/config/index.ts +0 -225
  111. package/src/config/validation-helpers.ts +0 -584
  112. package/src/config/validation.ts +0 -1548
  113. package/src/config-cache.ts +0 -45
  114. package/src/create-worker-preview.ts +0 -185
  115. package/src/create-worker-upload-form.ts +0 -254
  116. package/src/dev/dev-vars.ts +0 -36
  117. package/src/dev/dev.tsx +0 -395
  118. package/src/dev/local.tsx +0 -321
  119. package/src/dev/remote.tsx +0 -240
  120. package/src/dev/use-esbuild.ts +0 -115
  121. package/src/dialogs.tsx +0 -135
  122. package/src/durable.ts +0 -102
  123. package/src/entry.ts +0 -322
  124. package/src/environment-variables.ts +0 -35
  125. package/src/errors.ts +0 -11
  126. package/src/https-options.ts +0 -123
  127. package/src/index.tsx +0 -2859
  128. package/src/inspect.ts +0 -662
  129. package/src/intl-polyfill.d.ts +0 -139
  130. package/src/kv.ts +0 -408
  131. package/src/logger.ts +0 -66
  132. package/src/miniflare-cli/README.md +0 -30
  133. package/src/miniflare-cli/enum-keys.ts +0 -17
  134. package/src/miniflare-cli/index.ts +0 -41
  135. package/src/miniflare-cli/request-context.ts +0 -40
  136. package/src/module-collection.ts +0 -258
  137. package/src/open-in-browser.ts +0 -19
  138. package/src/package-manager.ts +0 -174
  139. package/src/pages.tsx +0 -2093
  140. package/src/parse.ts +0 -222
  141. package/src/paths.ts +0 -26
  142. package/src/proxy.ts +0 -478
  143. package/src/publish.ts +0 -721
  144. package/src/r2.ts +0 -50
  145. package/src/selfsigned.d.ts +0 -29
  146. package/src/sites.tsx +0 -326
  147. package/src/tail/filters.ts +0 -279
  148. package/src/tail/index.ts +0 -299
  149. package/src/tail/printing.ts +0 -67
  150. package/src/update-check.ts +0 -19
  151. package/src/user.tsx +0 -1214
  152. package/src/whoami.tsx +0 -71
  153. package/src/worker.ts +0 -181
  154. package/src/zones.ts +0 -73
  155. package/templates/static-asset-facade.js +0 -43
@@ -1,1010 +0,0 @@
1
- import * as fs from "node:fs";
2
- import getPort from "get-port";
3
- import patchConsole from "patch-console";
4
- import dedent from "ts-dedent";
5
- import Dev from "../dev/dev";
6
- import { setMockResponse, unsetAllMocks } from "./helpers/mock-cfetch";
7
- import { mockConsoleMethods } from "./helpers/mock-console";
8
- import { runInTempDir } from "./helpers/run-in-tmp";
9
- import { runWrangler } from "./helpers/run-wrangler";
10
- import writeWranglerToml from "./helpers/write-wrangler-toml";
11
-
12
- describe("wrangler dev", () => {
13
- runInTempDir();
14
- const std = mockConsoleMethods();
15
- afterEach(() => {
16
- (Dev as jest.Mock).mockClear();
17
- patchConsole(() => {});
18
- unsetAllMocks();
19
- });
20
-
21
- describe("compatibility-date", () => {
22
- it("should not warn if there is no wrangler.toml and no compatibility-date specified", async () => {
23
- fs.writeFileSync("index.js", `export default {};`);
24
- await runWrangler("dev index.js");
25
- expect(std.out).toMatchInlineSnapshot(`""`);
26
- expect(std.warn).toMatchInlineSnapshot(`""`);
27
- expect(std.err).toMatchInlineSnapshot(`""`);
28
- });
29
-
30
- it("should warn if there is a wrangler.toml but no compatibility-date", async () => {
31
- writeWranglerToml({
32
- main: "index.js",
33
- compatibility_date: undefined,
34
- });
35
- fs.writeFileSync("index.js", `export default {};`);
36
- await runWrangler("dev");
37
- const currentDate = new Date().toISOString().substring(0, 10);
38
- expect(std.out).toMatchInlineSnapshot(`""`);
39
- expect(std.warn.replaceAll(currentDate, "<current-date>"))
40
- .toMatchInlineSnapshot(`
41
- "▲ [WARNING] No compatibility_date was specified. Using today's date: <current-date>.
42
-
43
- Add one to your wrangler.toml file:
44
- \`\`\`
45
- compatibility_date = \\"<current-date>\\"
46
- \`\`\`
47
- or pass it in your terminal:
48
- \`\`\`
49
- --compatibility-date=<current-date>
50
- \`\`\`
51
- See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.
52
-
53
- "
54
- `);
55
- expect(std.err).toMatchInlineSnapshot(`""`);
56
- });
57
-
58
- it("should not warn if there is a wrangler.toml but compatibility-date is specified at the command line", async () => {
59
- writeWranglerToml({
60
- main: "index.js",
61
- compatibility_date: undefined,
62
- });
63
- fs.writeFileSync("index.js", `export default {};`);
64
- await runWrangler("dev --compatibility-date=2020-01-01");
65
- expect(std.out).toMatchInlineSnapshot(`""`);
66
- expect(std.warn).toMatchInlineSnapshot(`""`);
67
- expect(std.err).toMatchInlineSnapshot(`""`);
68
- });
69
- });
70
-
71
- describe("entry-points", () => {
72
- it("should error if there is no entry-point specified", async () => {
73
- writeWranglerToml();
74
-
75
- await expect(
76
- runWrangler("dev")
77
- ).rejects.toThrowErrorMatchingInlineSnapshot(
78
- `"Missing entry-point: The entry-point should be specified via the command line (e.g. \`wrangler dev path/to/script\`) or the \`main\` config field."`
79
- );
80
-
81
- expect(std.out).toMatchInlineSnapshot(`
82
- "
83
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
84
- `);
85
- expect(std.err).toMatchInlineSnapshot(`
86
- "X [ERROR] Missing entry-point: The entry-point should be specified via the command line (e.g. \`wrangler dev path/to/script\`) or the \`main\` config field.
87
-
88
- "
89
- `);
90
- });
91
-
92
- it("should use `main` from the top-level environment", async () => {
93
- writeWranglerToml({
94
- main: "index.js",
95
- });
96
- fs.writeFileSync("index.js", `export default {};`);
97
- await runWrangler("dev");
98
- expect((Dev as jest.Mock).mock.calls[0][0].entry.file).toMatch(
99
- /index\.js$/
100
- );
101
- expect(std.out).toMatchInlineSnapshot(`""`);
102
- expect(std.warn).toMatchInlineSnapshot(`""`);
103
- expect(std.err).toMatchInlineSnapshot(`""`);
104
- });
105
-
106
- it("should use `main` from a named environment", async () => {
107
- writeWranglerToml({
108
- env: {
109
- ENV1: {
110
- main: "index.js",
111
- },
112
- },
113
- });
114
- fs.writeFileSync("index.js", `export default {};`);
115
- await runWrangler("dev --env=ENV1");
116
- expect((Dev as jest.Mock).mock.calls[0][0].entry.file).toMatch(
117
- /index\.js$/
118
- );
119
- expect(std.out).toMatchInlineSnapshot(`""`);
120
- expect(std.warn).toMatchInlineSnapshot(`""`);
121
- expect(std.err).toMatchInlineSnapshot(`""`);
122
- });
123
-
124
- it("should use `main` from a named environment, rather than the top-level", async () => {
125
- writeWranglerToml({
126
- main: "other.js",
127
- env: {
128
- ENV1: {
129
- main: "index.js",
130
- },
131
- },
132
- });
133
- fs.writeFileSync("index.js", `export default {};`);
134
- await runWrangler("dev --env=ENV1");
135
- expect((Dev as jest.Mock).mock.calls[0][0].entry.file).toMatch(
136
- /index\.js$/
137
- );
138
- expect(std.out).toMatchInlineSnapshot(`""`);
139
- expect(std.warn).toMatchInlineSnapshot(`""`);
140
- expect(std.err).toMatchInlineSnapshot(`""`);
141
- });
142
- });
143
-
144
- describe("host", () => {
145
- it("should resolve a host to its zone", async () => {
146
- writeWranglerToml({
147
- main: "index.js",
148
- });
149
- fs.writeFileSync("index.js", `export default {};`);
150
- mockGetZones("some-host.com", [{ id: "some-zone-id" }]);
151
- await runWrangler("dev --host some-host.com");
152
- expect((Dev as jest.Mock).mock.calls[0][0]).toEqual(
153
- expect.objectContaining({
154
- host: "some-host.com",
155
- zone: "some-zone-id",
156
- })
157
- );
158
- });
159
-
160
- it("should read wrangler.toml's dev.host", async () => {
161
- writeWranglerToml({
162
- main: "index.js",
163
- dev: {
164
- host: "some-host.com",
165
- },
166
- });
167
- fs.writeFileSync("index.js", `export default {};`);
168
- mockGetZones("some-host.com", [{ id: "some-zone-id" }]);
169
- await runWrangler("dev");
170
- expect((Dev as jest.Mock).mock.calls[0][0].host).toEqual("some-host.com");
171
- });
172
-
173
- it("should read --route", async () => {
174
- writeWranglerToml({
175
- main: "index.js",
176
- });
177
- fs.writeFileSync("index.js", `export default {};`);
178
- mockGetZones("some-host.com", [{ id: "some-zone-id" }]);
179
- await runWrangler("dev --route http://some-host.com/some/path/*");
180
- expect((Dev as jest.Mock).mock.calls[0][0].host).toEqual("some-host.com");
181
- });
182
-
183
- it("should read wrangler.toml's routes", async () => {
184
- writeWranglerToml({
185
- main: "index.js",
186
- routes: [
187
- "http://some-host.com/some/path/*",
188
- "http://some-other-host.com/path/*",
189
- ],
190
- });
191
- fs.writeFileSync("index.js", `export default {};`);
192
- mockGetZones("some-host.com", [{ id: "some-zone-id" }]);
193
- await runWrangler("dev");
194
- expect((Dev as jest.Mock).mock.calls[0][0].host).toEqual("some-host.com");
195
- });
196
-
197
- it("should read wrangler.toml's environment specific routes", async () => {
198
- writeWranglerToml({
199
- main: "index.js",
200
- routes: [
201
- "http://a-host.com/some/path/*",
202
- "http://another-host.com/path/*",
203
- ],
204
- env: {
205
- staging: {
206
- routes: [
207
- "http://some-host.com/some/path/*",
208
- "http://some-other-host.com/path/*",
209
- ],
210
- },
211
- },
212
- });
213
- fs.writeFileSync("index.js", `export default {};`);
214
- mockGetZones("some-host.com", [{ id: "some-zone-id" }]);
215
- await runWrangler("dev --env staging");
216
- expect((Dev as jest.Mock).mock.calls[0][0].host).toEqual("some-host.com");
217
- });
218
-
219
- it("should strip leading `*` from given host when deducing a zone id", async () => {
220
- writeWranglerToml({
221
- main: "index.js",
222
- route: "*some-host.com/some/path/*",
223
- });
224
- fs.writeFileSync("index.js", `export default {};`);
225
- mockGetZones("some-host.com", [{ id: "some-zone-id" }]);
226
- await runWrangler("dev");
227
- expect((Dev as jest.Mock).mock.calls[0][0].host).toEqual("some-host.com");
228
- });
229
-
230
- it("should strip leading `*.` from given host when deducing a zone id", async () => {
231
- writeWranglerToml({
232
- main: "index.js",
233
- route: "*.some-host.com/some/path/*",
234
- });
235
- fs.writeFileSync("index.js", `export default {};`);
236
- mockGetZones("some-host.com", [{ id: "some-zone-id" }]);
237
- await runWrangler("dev");
238
- expect((Dev as jest.Mock).mock.calls[0][0].host).toEqual("some-host.com");
239
- });
240
-
241
- it("should, when provided, use a configured zone_id", async () => {
242
- writeWranglerToml({
243
- main: "index.js",
244
- routes: [
245
- { pattern: "https://some-domain.com/*", zone_id: "some-zone-id" },
246
- ],
247
- });
248
- fs.writeFileSync("index.js", `export default {};`);
249
- await runWrangler("dev");
250
- expect((Dev as jest.Mock).mock.calls[0][0]).toEqual(
251
- expect.objectContaining({
252
- host: "some-domain.com",
253
- zone: "some-zone-id",
254
- })
255
- );
256
- });
257
-
258
- it("should, when provided, use a zone_name to get a zone_id", async () => {
259
- writeWranglerToml({
260
- main: "index.js",
261
- routes: [
262
- { pattern: "https://some-domain.com/*", zone_name: "some-zone.com" },
263
- ],
264
- });
265
- fs.writeFileSync("index.js", `export default {};`);
266
- mockGetZones("some-zone.com", [{ id: "a-zone-id" }]);
267
- await runWrangler("dev");
268
- expect((Dev as jest.Mock).mock.calls[0][0]).toEqual(
269
- expect.objectContaining({
270
- // note that it uses the provided zone_name as a host too
271
- host: "some-zone.com",
272
- zone: "a-zone-id",
273
- })
274
- );
275
- });
276
-
277
- it("given a long host, it should use the longest subdomain that resolves to a zone", async () => {
278
- writeWranglerToml({
279
- main: "index.js",
280
- });
281
- fs.writeFileSync("index.js", `export default {};`);
282
- mockGetZones("111.222.333.some-host.com", []);
283
- mockGetZones("222.333.some-host.com", []);
284
- mockGetZones("333.some-host.com", [{ id: "some-zone-id" }]);
285
- await runWrangler("dev --host 111.222.333.some-host.com");
286
- expect((Dev as jest.Mock).mock.calls[0][0]).toEqual(
287
- expect.objectContaining({
288
- host: "111.222.333.some-host.com",
289
- zone: "some-zone-id",
290
- })
291
- );
292
- });
293
-
294
- it("should, in order, use args.host/config.dev.host/args.routes/(config.route|config.routes)", async () => {
295
- // This test might seem like it's testing implementation details, but let's be specific and consider it a spec
296
-
297
- fs.writeFileSync("index.js", `export default {};`);
298
-
299
- // config.routes
300
- mockGetZones("5.some-host.com", [{ id: "some-zone-id-5" }]);
301
- writeWranglerToml({
302
- main: "index.js",
303
- routes: ["http://5.some-host.com/some/path/*"],
304
- });
305
- await runWrangler("dev");
306
- expect((Dev as jest.Mock).mock.calls[0][0]).toEqual(
307
- expect.objectContaining({
308
- host: "5.some-host.com",
309
- zone: "some-zone-id-5",
310
- })
311
- );
312
- (Dev as jest.Mock).mockClear();
313
-
314
- // config.route
315
- mockGetZones("4.some-host.com", [{ id: "some-zone-id-4" }]);
316
- writeWranglerToml({
317
- main: "index.js",
318
- route: "https://4.some-host.com/some/path/*",
319
- });
320
- await runWrangler("dev");
321
- expect((Dev as jest.Mock).mock.calls[0][0]).toEqual(
322
- expect.objectContaining({
323
- host: "4.some-host.com",
324
- zone: "some-zone-id-4",
325
- })
326
- );
327
- (Dev as jest.Mock).mockClear();
328
-
329
- // --routes
330
- mockGetZones("3.some-host.com", [{ id: "some-zone-id-3" }]);
331
- writeWranglerToml({
332
- main: "index.js",
333
- route: "https://4.some-host.com/some/path/*",
334
- });
335
- await runWrangler("dev --routes http://3.some-host.com/some/path/*");
336
- expect((Dev as jest.Mock).mock.calls[0][0]).toEqual(
337
- expect.objectContaining({
338
- host: "3.some-host.com",
339
- zone: "some-zone-id-3",
340
- })
341
- );
342
- (Dev as jest.Mock).mockClear();
343
-
344
- // config.dev.host
345
- mockGetZones("2.some-host.com", [{ id: "some-zone-id-2" }]);
346
- writeWranglerToml({
347
- main: "index.js",
348
- dev: {
349
- host: `2.some-host.com`,
350
- },
351
- route: "4.some-host.com/some/path/*",
352
- });
353
- await runWrangler("dev --routes http://3.some-host.com/some/path/*");
354
- expect((Dev as jest.Mock).mock.calls[0][0]).toEqual(
355
- expect.objectContaining({
356
- host: "2.some-host.com",
357
- zone: "some-zone-id-2",
358
- })
359
- );
360
- (Dev as jest.Mock).mockClear();
361
-
362
- // --host
363
- mockGetZones("1.some-host.com", [{ id: "some-zone-id-1" }]);
364
- writeWranglerToml({
365
- main: "index.js",
366
- dev: {
367
- host: `2.some-host.com`,
368
- },
369
- route: "4.some-host.com/some/path/*",
370
- });
371
- await runWrangler(
372
- "dev --routes http://3.some-host.com/some/path/* --host 1.some-host.com"
373
- );
374
- expect((Dev as jest.Mock).mock.calls[0][0]).toEqual(
375
- expect.objectContaining({
376
- host: "1.some-host.com",
377
- zone: "some-zone-id-1",
378
- })
379
- );
380
- (Dev as jest.Mock).mockClear();
381
- });
382
-
383
- it("should error if a host can't resolve to a zone", async () => {
384
- writeWranglerToml({
385
- main: "index.js",
386
- });
387
- fs.writeFileSync("index.js", `export default {};`);
388
- mockGetZones("some-host.com", []);
389
- await expect(
390
- runWrangler("dev --host some-host.com")
391
- ).rejects.toThrowErrorMatchingInlineSnapshot(
392
- `"Could not find zone for some-host.com"`
393
- );
394
- });
395
-
396
- it("should not try to resolve a zone when starting in local mode", async () => {
397
- writeWranglerToml({
398
- main: "index.js",
399
- });
400
- fs.writeFileSync("index.js", `export default {};`);
401
- await runWrangler("dev --host some-host.com --local");
402
- expect((Dev as jest.Mock).mock.calls[0][0].zone).toEqual(undefined);
403
- });
404
- });
405
-
406
- describe("custom builds", () => {
407
- it("should run a custom build before starting `dev`", async () => {
408
- writeWranglerToml({
409
- build: {
410
- command: `node -e "console.log('custom build'); require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')"`,
411
- },
412
- });
413
-
414
- await runWrangler("dev index.js");
415
-
416
- expect(fs.readFileSync("index.js", "utf-8")).toMatchInlineSnapshot(
417
- `"export default { fetch(){ return new Response(123) } }"`
418
- );
419
-
420
- // and the command would pass through
421
- expect((Dev as jest.Mock).mock.calls[0][0].build).toEqual({
422
- command:
423
- "node -e \"console.log('custom build'); require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')\"",
424
- cwd: undefined,
425
- watch_dir: "src",
426
- });
427
- expect(std.out).toMatchInlineSnapshot(
428
- `"Running custom build: node -e \\"console.log('custom build'); require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')\\""`
429
- );
430
- expect(std.err).toMatchInlineSnapshot(`""`);
431
- expect(std.warn).toMatchInlineSnapshot(`""`);
432
- });
433
-
434
- if (process.platform !== "win32") {
435
- it("should run a custom build of multiple steps combined by && before starting `dev`", async () => {
436
- writeWranglerToml({
437
- build: {
438
- command: `echo "custom build" && echo "export default { fetch(){ return new Response(123) } }" > index.js`,
439
- },
440
- });
441
-
442
- await runWrangler("dev index.js");
443
-
444
- expect(fs.readFileSync("index.js", "utf-8")).toMatchInlineSnapshot(`
445
- "export default { fetch(){ return new Response(123) } }
446
- "
447
- `);
448
-
449
- expect(std.out).toMatchInlineSnapshot(
450
- `"Running custom build: echo \\"custom build\\" && echo \\"export default { fetch(){ return new Response(123) } }\\" > index.js"`
451
- );
452
- expect(std.err).toMatchInlineSnapshot(`""`);
453
- expect(std.warn).toMatchInlineSnapshot(`""`);
454
- });
455
- }
456
-
457
- it("should throw an error if the entry doesn't exist after the build finishes", async () => {
458
- writeWranglerToml({
459
- main: "index.js",
460
- build: {
461
- command: `node -e "console.log('custom build');"`,
462
- },
463
- });
464
-
465
- await expect(runWrangler("dev")).rejects
466
- .toThrowErrorMatchingInlineSnapshot(`
467
- "The expected output file at \\"index.js\\" was not found after running custom build: node -e \\"console.log('custom build');\\".
468
- The \`main\` property in wrangler.toml should point to the file generated by the custom build."
469
- `);
470
- expect(std.out).toMatchInlineSnapshot(`
471
- "Running custom build: node -e \\"console.log('custom build');\\"
472
-
473
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
474
- `);
475
- expect(std.err).toMatchInlineSnapshot(`
476
- "X [ERROR] The expected output file at \\"index.js\\" was not found after running custom build: node -e \\"console.log('custom build');\\".
477
-
478
- The \`main\` property in wrangler.toml should point to the file generated by the custom build.
479
-
480
- "
481
- `);
482
- expect(std.warn).toMatchInlineSnapshot(`""`);
483
- });
484
- });
485
-
486
- describe("upstream-protocol", () => {
487
- it("should default upstream-protocol to `https`", async () => {
488
- writeWranglerToml({
489
- main: "index.js",
490
- });
491
- fs.writeFileSync("index.js", `export default {};`);
492
- await runWrangler("dev");
493
- expect((Dev as jest.Mock).mock.calls[0][0].upstreamProtocol).toEqual(
494
- "https"
495
- );
496
- expect(std.out).toMatchInlineSnapshot(`""`);
497
- expect(std.warn).toMatchInlineSnapshot(`""`);
498
- expect(std.err).toMatchInlineSnapshot(`""`);
499
- });
500
-
501
- it("should warn if `--upstream-protocol=http` is used", async () => {
502
- writeWranglerToml({
503
- main: "index.js",
504
- });
505
- fs.writeFileSync("index.js", `export default {};`);
506
- await runWrangler("dev --upstream-protocol=http");
507
- expect((Dev as jest.Mock).mock.calls[0][0].upstreamProtocol).toEqual(
508
- "http"
509
- );
510
- expect(std.out).toMatchInlineSnapshot(`""`);
511
- expect(std.warn).toMatchInlineSnapshot(`
512
- "▲ [WARNING] Setting upstream-protocol to http is not currently implemented.
513
-
514
- If this is required in your project, please add your use case to the following issue:
515
- https://github.com/cloudflare/wrangler2/issues/583.
516
-
517
- "
518
- `);
519
- expect(std.err).toMatchInlineSnapshot(`""`);
520
- });
521
- });
522
-
523
- describe("local-protocol", () => {
524
- it("should default local-protocol to `http`", async () => {
525
- writeWranglerToml({
526
- main: "index.js",
527
- });
528
- fs.writeFileSync("index.js", `export default {};`);
529
- await runWrangler("dev");
530
- expect((Dev as jest.Mock).mock.calls[0][0].localProtocol).toEqual("http");
531
- expect(std.out).toMatchInlineSnapshot(`""`);
532
- expect(std.warn).toMatchInlineSnapshot(`""`);
533
- expect(std.err).toMatchInlineSnapshot(`""`);
534
- });
535
-
536
- it("should use `local_protocol` from `wrangler.toml`, if available", async () => {
537
- writeWranglerToml({
538
- main: "index.js",
539
- dev: {
540
- local_protocol: "https",
541
- },
542
- });
543
- fs.writeFileSync("index.js", `export default {};`);
544
- await runWrangler("dev");
545
- expect((Dev as jest.Mock).mock.calls[0][0].localProtocol).toEqual(
546
- "https"
547
- );
548
- expect(std.out).toMatchInlineSnapshot(`""`);
549
- expect(std.warn).toMatchInlineSnapshot(`""`);
550
- expect(std.err).toMatchInlineSnapshot(`""`);
551
- });
552
-
553
- it("should use --local-protocol command line arg, if provided", async () => {
554
- // Here we show that the command line overrides the wrangler.toml by
555
- // setting the config to https, and then setting it back to http on the command line.
556
- writeWranglerToml({
557
- main: "index.js",
558
- dev: {
559
- local_protocol: "https",
560
- },
561
- });
562
- fs.writeFileSync("index.js", `export default {};`);
563
- await runWrangler("dev --local-protocol=http");
564
- expect((Dev as jest.Mock).mock.calls[0][0].localProtocol).toEqual("http");
565
- expect(std.out).toMatchInlineSnapshot(`""`);
566
- expect(std.warn).toMatchInlineSnapshot(`""`);
567
- expect(std.err).toMatchInlineSnapshot(`""`);
568
- });
569
- });
570
-
571
- describe("ip", () => {
572
- it("should default ip to localhost", async () => {
573
- writeWranglerToml({
574
- main: "index.js",
575
- });
576
- fs.writeFileSync("index.js", `export default {};`);
577
- await runWrangler("dev");
578
- expect((Dev as jest.Mock).mock.calls[0][0].ip).toEqual("localhost");
579
- expect(std.out).toMatchInlineSnapshot(`""`);
580
- expect(std.warn).toMatchInlineSnapshot(`""`);
581
- expect(std.err).toMatchInlineSnapshot(`""`);
582
- });
583
-
584
- it("should use to `ip` from `wrangler.toml`, if available", async () => {
585
- writeWranglerToml({
586
- main: "index.js",
587
- dev: {
588
- ip: "0.0.0.0",
589
- },
590
- });
591
- fs.writeFileSync("index.js", `export default {};`);
592
- await runWrangler("dev");
593
- expect((Dev as jest.Mock).mock.calls[0][0].ip).toEqual("0.0.0.0");
594
- expect(std.out).toMatchInlineSnapshot(`""`);
595
- expect(std.warn).toMatchInlineSnapshot(`""`);
596
- expect(std.err).toMatchInlineSnapshot(`""`);
597
- });
598
-
599
- it("should use --ip command line arg, if provided", async () => {
600
- writeWranglerToml({
601
- main: "index.js",
602
- dev: {
603
- ip: "1.1.1.1",
604
- },
605
- });
606
- fs.writeFileSync("index.js", `export default {};`);
607
- await runWrangler("dev --ip=0.0.0.0");
608
- expect((Dev as jest.Mock).mock.calls[0][0].ip).toEqual("0.0.0.0");
609
- expect(std.out).toMatchInlineSnapshot(`""`);
610
- expect(std.warn).toMatchInlineSnapshot(`""`);
611
- expect(std.err).toMatchInlineSnapshot(`""`);
612
- });
613
- });
614
-
615
- describe("port", () => {
616
- it("should default port to 8787 if it is not in use", async () => {
617
- writeWranglerToml({
618
- main: "index.js",
619
- });
620
- fs.writeFileSync("index.js", `export default {};`);
621
- await runWrangler("dev");
622
- expect((Dev as jest.Mock).mock.calls[0][0].port).toEqual(8787);
623
- expect(std.out).toMatchInlineSnapshot(`""`);
624
- expect(std.warn).toMatchInlineSnapshot(`""`);
625
- expect(std.err).toMatchInlineSnapshot(`""`);
626
- });
627
-
628
- it("should use to `port` from `wrangler.toml`, if available", async () => {
629
- writeWranglerToml({
630
- main: "index.js",
631
- dev: {
632
- port: 8888,
633
- },
634
- });
635
- fs.writeFileSync("index.js", `export default {};`);
636
- // Mock `getPort()` to resolve to a completely different port.
637
- (getPort as jest.Mock).mockResolvedValue(98765);
638
-
639
- await runWrangler("dev");
640
- expect((Dev as jest.Mock).mock.calls[0][0].port).toEqual(8888);
641
- expect(std.out).toMatchInlineSnapshot(`""`);
642
- expect(std.warn).toMatchInlineSnapshot(`""`);
643
- expect(std.err).toMatchInlineSnapshot(`""`);
644
- });
645
-
646
- it("should use --port command line arg, if provided", async () => {
647
- writeWranglerToml({
648
- main: "index.js",
649
- dev: {
650
- port: 8888,
651
- },
652
- });
653
- fs.writeFileSync("index.js", `export default {};`);
654
- // Mock `getPort()` to resolve to a completely different port.
655
- (getPort as jest.Mock).mockResolvedValue(98765);
656
-
657
- await runWrangler("dev --port=9999");
658
- expect((Dev as jest.Mock).mock.calls[0][0].port).toEqual(9999);
659
- expect(std.out).toMatchInlineSnapshot(`""`);
660
- expect(std.warn).toMatchInlineSnapshot(`""`);
661
- expect(std.err).toMatchInlineSnapshot(`""`);
662
- });
663
-
664
- it("should use a different port to the default if it is in use", async () => {
665
- writeWranglerToml({
666
- main: "index.js",
667
- });
668
- fs.writeFileSync("index.js", `export default {};`);
669
- // Mock `getPort()` to resolve to a completely different port.
670
- (getPort as jest.Mock).mockResolvedValue(98765);
671
-
672
- await runWrangler("dev");
673
- expect((Dev as jest.Mock).mock.calls[0][0].port).toEqual(98765);
674
- expect(std.out).toMatchInlineSnapshot(`""`);
675
- expect(std.warn).toMatchInlineSnapshot(`""`);
676
- expect(std.err).toMatchInlineSnapshot(`""`);
677
- });
678
- });
679
-
680
- describe("durable_objects", () => {
681
- it("should warn if there are remote Durable Objects, or missing migrations for local Durable Objects", async () => {
682
- writeWranglerToml({
683
- main: "index.js",
684
- durable_objects: {
685
- bindings: [
686
- { name: "NAME_1", class_name: "CLASS_1" },
687
- {
688
- name: "NAME_2",
689
- class_name: "CLASS_2",
690
- script_name: "SCRIPT_A",
691
- },
692
- { name: "NAME_3", class_name: "CLASS_3" },
693
- {
694
- name: "NAME_4",
695
- class_name: "CLASS_4",
696
- script_name: "SCRIPT_B",
697
- },
698
- ],
699
- },
700
- });
701
- fs.writeFileSync("index.js", `export default {};`);
702
- await runWrangler("dev");
703
- expect((Dev as jest.Mock).mock.calls[0][0].ip).toEqual("localhost");
704
- expect(std.out).toMatchInlineSnapshot(`
705
- "Your worker has access to the following bindings:
706
- - Durable Objects:
707
- - NAME_1: CLASS_1
708
- - NAME_2: CLASS_2 (defined in SCRIPT_A)
709
- - NAME_3: CLASS_3
710
- - NAME_4: CLASS_4 (defined in SCRIPT_B)"
711
- `);
712
- expect(std.warn).toMatchInlineSnapshot(`
713
- "▲ [WARNING] Processing wrangler.toml configuration:
714
-
715
- - In wrangler.toml, you have configured [durable_objects] exported by this Worker (CLASS_1,
716
- CLASS_3), but no [migrations] for them. This may not work as expected until you add a [migrations]
717
- section to your wrangler.toml. Add this configuration to your wrangler.toml:
718
-
719
- \`\`\`
720
- [[migrations]]
721
- tag = \\"v1\\" # Should be unique for each entry
722
- new_classes = [\\"CLASS_1\\", \\"CLASS_3\\"]
723
- \`\`\`
724
-
725
- Refer to
726
- https://developers.cloudflare.com/workers/learning/using-durable-objects/#durable-object-migrations-in-wranglertoml
727
- for more details.
728
-
729
-
730
- ▲ [WARNING] WARNING: You have Durable Object bindings that are not defined locally in the worker being developed.
731
-
732
- Be aware that changes to the data stored in these Durable Objects will be permanent and affect the
733
- live instances.
734
- Remote Durable Objects that are affected:
735
- - {\\"name\\":\\"NAME_2\\",\\"class_name\\":\\"CLASS_2\\",\\"script_name\\":\\"SCRIPT_A\\"}
736
- - {\\"name\\":\\"NAME_4\\",\\"class_name\\":\\"CLASS_4\\",\\"script_name\\":\\"SCRIPT_B\\"}
737
-
738
- "
739
- `);
740
- expect(std.err).toMatchInlineSnapshot(`""`);
741
- });
742
- });
743
-
744
- describe(".dev.vars", () => {
745
- it("should override `vars` bindings from `wrangler.toml` with values in `.dev.vars`", async () => {
746
- fs.writeFileSync("index.js", `export default {};`);
747
-
748
- const localVarsEnvContent = dedent`
749
- # Preceding comment
750
- VAR_1="var #1 value" # End of line comment
751
- VAR_3="var #3 value"
752
- VAR_MULTI_LINE_1="A: line 1
753
- line 2"
754
- VAR_MULTI_LINE_2="B: line 1\\nline 2"
755
- EMPTY=
756
- UNQUOTED= unquoted value
757
- `;
758
- fs.writeFileSync(".dev.vars", localVarsEnvContent, "utf8");
759
-
760
- writeWranglerToml({
761
- main: "index.js",
762
- vars: {
763
- VAR_1: "original value 1",
764
- VAR_2: "original value 2", // should not get overridden
765
- VAR_3: "original value 3",
766
- VAR_MULTI_LINE_1: "original multi-line 1",
767
- VAR_MULTI_LINE_2: "original multi-line 2",
768
- EMPTY: "original empty",
769
- UNQUOTED: "original unquoted",
770
- },
771
- });
772
- await runWrangler("dev");
773
- const varBindings: Record<string, unknown> = (Dev as jest.Mock).mock
774
- .calls[0][0].bindings.vars;
775
-
776
- expect(varBindings).toEqual({
777
- VAR_1: "var #1 value",
778
- VAR_2: "original value 2",
779
- VAR_3: "var #3 value",
780
- VAR_MULTI_LINE_1: "A: line 1\nline 2",
781
- VAR_MULTI_LINE_2: "B: line 1\nline 2",
782
- EMPTY: "",
783
- UNQUOTED: "unquoted value", // Note that whitespace is trimmed
784
- });
785
- expect(std.out).toMatchInlineSnapshot(`
786
- "Using vars defined in .dev.vars
787
- Your worker has access to the following bindings:
788
- - Vars:
789
- - VAR_1: \\"(hidden)\\"
790
- - VAR_2: \\"original value 2\\"
791
- - VAR_3: \\"(hidden)\\"
792
- - VAR_MULTI_LINE_1: \\"(hidden)\\"
793
- - VAR_MULTI_LINE_2: \\"(hidden)\\"
794
- - EMPTY: \\"(hidden)\\"
795
- - UNQUOTED: \\"(hidden)\\""
796
- `);
797
- expect(std.warn).toMatchInlineSnapshot(`""`);
798
- expect(std.err).toMatchInlineSnapshot(`""`);
799
- });
800
- });
801
-
802
- describe("site", () => {
803
- it("should error if --site is used with no value", async () => {
804
- await expect(
805
- runWrangler("dev --site")
806
- ).rejects.toThrowErrorMatchingInlineSnapshot(
807
- `"Not enough arguments following: site"`
808
- );
809
-
810
- expect(std).toMatchInlineSnapshot(`
811
- Object {
812
- "debug": "",
813
- "err": "X [ERROR] Not enough arguments following: site
814
-
815
- ",
816
- "out": "
817
- wrangler dev [script]
818
-
819
- 👂 Start a local server for developing your worker
820
-
821
- Positionals:
822
- script The path to an entry point for your worker [string]
823
-
824
- Flags:
825
- -c, --config Path to .toml configuration file [string]
826
- -h, --help Show help [boolean]
827
- -v, --version Show version number [boolean]
828
-
829
- Options:
830
- --name Name of the worker [string]
831
- --format Choose an entry type [deprecated] [choices: \\"modules\\", \\"service-worker\\"]
832
- -e, --env Perform on a specific environment [string]
833
- --compatibility-date Date to use for compatibility checks [string]
834
- --compatibility-flags, --compatibility-flag Flags to use for compatibility checks [array]
835
- --latest Use the latest version of the worker runtime [boolean] [default: true]
836
- --ip IP address to listen on, defaults to \`localhost\` [string]
837
- --port Port to listen on [number]
838
- --inspector-port Port for devtools to connect to [number]
839
- --routes, --route Routes to upload [array]
840
- --host Host to forward requests to, defaults to the zone of project [string]
841
- --local-protocol Protocol to listen to requests on, defaults to http. [choices: \\"http\\", \\"https\\"]
842
- --experimental-public Static assets to be served [string]
843
- --site Root folder of static assets for Workers Sites [string]
844
- --site-include Array of .gitignore-style patterns that match file or directory names from the sites directory. Only matched items will be uploaded. [array]
845
- --site-exclude Array of .gitignore-style patterns that match file or directory names from the sites directory. Matched items will not be uploaded. [array]
846
- --upstream-protocol Protocol to forward requests to host on, defaults to https. [choices: \\"http\\", \\"https\\"]
847
- --jsx-factory The function that is called for each JSX element [string]
848
- --jsx-fragment The function that is called for each JSX fragment [string]
849
- --tsconfig Path to a custom tsconfig.json file [string]
850
- -l, --local Run on my machine [boolean] [default: false]
851
- --minify Minify the script [boolean]
852
- --node-compat Enable node.js compatibility [boolean]
853
- --experimental-enable-local-persistence Enable persistence for this session (only for local mode) [boolean]
854
- --inspect Enable dev tools [deprecated] [boolean]",
855
- "warn": "",
856
- }
857
- `);
858
- });
859
-
860
- it("should error if --experimental-public and --site are used together", async () => {
861
- writeWranglerToml({
862
- main: "./index.js",
863
- });
864
- fs.writeFileSync("index.js", `export default {};`);
865
- await expect(
866
- runWrangler("dev --experimental-public abc --site xyz")
867
- ).rejects.toThrowErrorMatchingInlineSnapshot(
868
- `"Cannot use --experimental-public and a Site configuration together."`
869
- );
870
- });
871
-
872
- it("should error if --experimental-public and config.site are used together", async () => {
873
- writeWranglerToml({
874
- main: "./index.js",
875
- site: {
876
- bucket: "xyz",
877
- },
878
- });
879
- fs.writeFileSync("index.js", `export default {};`);
880
- await expect(
881
- runWrangler("dev --experimental-public abc")
882
- ).rejects.toThrowErrorMatchingInlineSnapshot(
883
- `"Cannot use --experimental-public and a Site configuration together."`
884
- );
885
- });
886
- });
887
-
888
- describe("--inspect", () => {
889
- it("should warn if --inspect is used", async () => {
890
- fs.writeFileSync("index.js", `export default {};`);
891
- await runWrangler("dev index.js --inspect");
892
- expect(std).toMatchInlineSnapshot(`
893
- Object {
894
- "debug": "",
895
- "err": "",
896
- "out": "",
897
- "warn": "▲ [WARNING] Passing --inspect is unnecessary, now you can always connect to devtools.
898
-
899
- ",
900
- }
901
- `);
902
- });
903
- });
904
-
905
- describe("service bindings", () => {
906
- it("should warn when using service bindings", async () => {
907
- writeWranglerToml({
908
- services: [
909
- { binding: "WorkerA", service: "A" },
910
- { binding: "WorkerB", service: "B", environment: "staging" },
911
- ],
912
- });
913
- fs.writeFileSync("index.js", `export default {};`);
914
- await runWrangler("dev index.js");
915
- expect(std).toMatchInlineSnapshot(`
916
- Object {
917
- "debug": "",
918
- "err": "",
919
- "out": "Your worker has access to the following bindings:
920
- - Services:
921
- - WorkerA: A
922
- - WorkerB: B - staging",
923
- "warn": "▲ [WARNING] Processing wrangler.toml configuration:
924
-
925
- - \\"services\\" fields are experimental and may change or break at any time.
926
-
927
-
928
- ▲ [WARNING] This worker is bound to live services: WorkerA (A), WorkerB (B@staging)
929
-
930
- ",
931
- }
932
- `);
933
- });
934
- });
935
-
936
- describe("print bindings", () => {
937
- it("should print bindings", async () => {
938
- writeWranglerToml({
939
- services: [
940
- { binding: "WorkerA", service: "A" },
941
- { binding: "WorkerB", service: "B", environment: "staging" },
942
- ],
943
- });
944
- fs.writeFileSync("index.js", `export default {};`);
945
- await runWrangler("dev index.js");
946
- expect(std).toMatchInlineSnapshot(`
947
- Object {
948
- "debug": "",
949
- "err": "",
950
- "out": "Your worker has access to the following bindings:
951
- - Services:
952
- - WorkerA: A
953
- - WorkerB: B - staging",
954
- "warn": "▲ [WARNING] Processing wrangler.toml configuration:
955
-
956
- - \\"services\\" fields are experimental and may change or break at any time.
957
-
958
-
959
- ▲ [WARNING] This worker is bound to live services: WorkerA (A), WorkerB (B@staging)
960
-
961
- ",
962
- }
963
- `);
964
- });
965
-
966
- it("should mask vars that were overriden in .dev.vars", async () => {
967
- writeWranglerToml({
968
- vars: {
969
- variable: 123,
970
- overriden: "original values",
971
- },
972
- });
973
- fs.writeFileSync(
974
- ".dev.vars",
975
- `
976
- SECRET = "A secret"
977
- overriden = "overriden value"
978
- `
979
- );
980
- fs.writeFileSync("index.js", `export default {};`);
981
- await runWrangler("dev index.js");
982
- expect(std).toMatchInlineSnapshot(`
983
- Object {
984
- "debug": "",
985
- "err": "",
986
- "out": "Using vars defined in .dev.vars
987
- Your worker has access to the following bindings:
988
- - Vars:
989
- - variable: \\"123\\"
990
- - overriden: \\"(hidden)\\"
991
- - SECRET: \\"(hidden)\\"",
992
- "warn": "",
993
- }
994
- `);
995
- });
996
- });
997
- });
998
-
999
- function mockGetZones(domain: string, zones: { id: string }[] = []) {
1000
- const removeMock = setMockResponse(
1001
- "/zones",
1002
- "GET",
1003
- (_urlPieces, _init, queryParams) => {
1004
- expect([...queryParams.entries()]).toEqual([["name", domain]]);
1005
- // Because the API URL `/zones` is the same for each request, we can get into a situation where earlier mocks get triggered for later requests. So, we simply clear the mock on every trigger.
1006
- removeMock();
1007
- return zones;
1008
- }
1009
- );
1010
- }