wrangler 0.0.0-e29a241 → 0.0.0-e2f9bb2

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 (88) hide show
  1. package/README.md +25 -14
  2. package/bin/wrangler.js +13 -1
  3. package/miniflare-dist/index.mjs +4828 -21
  4. package/package.json +29 -24
  5. package/pages/functions/buildPlugin.ts +92 -0
  6. package/pages/functions/buildWorker.ts +80 -4
  7. package/pages/functions/filepath-routing.test.ts +11 -0
  8. package/pages/functions/filepath-routing.ts +8 -0
  9. package/pages/functions/routes.ts +6 -1
  10. package/pages/functions/template-plugin.ts +146 -0
  11. package/pages/functions/template-worker.ts +21 -8
  12. package/src/__tests__/config-cache.test.ts +36 -0
  13. package/src/__tests__/configuration.test.ts +692 -321
  14. package/src/__tests__/dev.test.tsx +284 -18
  15. package/src/__tests__/guess-worker-format.test.ts +28 -1
  16. package/src/__tests__/helpers/mock-cfetch.ts +5 -1
  17. package/src/__tests__/helpers/mock-console.ts +20 -3
  18. package/src/__tests__/helpers/mock-dialogs.ts +24 -0
  19. package/src/__tests__/helpers/mock-http-server.ts +46 -0
  20. package/src/__tests__/helpers/mock-istty.ts +27 -0
  21. package/src/__tests__/helpers/mock-oauth-flow.ts +255 -0
  22. package/src/__tests__/helpers/run-in-tmp.ts +7 -0
  23. package/src/__tests__/helpers/write-worker-source.ts +31 -0
  24. package/src/__tests__/https-options.test.ts +5 -2
  25. package/src/__tests__/index.test.ts +27 -769
  26. package/src/__tests__/init.test.ts +1042 -0
  27. package/src/__tests__/jest.setup.ts +4 -4
  28. package/src/__tests__/kv.test.ts +133 -61
  29. package/src/__tests__/logger.test.ts +115 -0
  30. package/src/__tests__/pages.test.ts +311 -26
  31. package/src/__tests__/publish.test.ts +2789 -618
  32. package/src/__tests__/r2.test.ts +26 -10
  33. package/src/__tests__/route.test.ts +4 -4
  34. package/src/__tests__/secret.test.ts +55 -34
  35. package/src/__tests__/tail.test.ts +146 -20
  36. package/src/__tests__/user.test.ts +131 -0
  37. package/src/__tests__/whoami.test.tsx +14 -9
  38. package/src/bundle.ts +30 -3
  39. package/src/cfetch/internal.ts +0 -2
  40. package/src/cli.ts +5 -11
  41. package/src/config/README.md +1 -1
  42. package/src/config/config.ts +13 -53
  43. package/src/config/environment.ts +88 -4
  44. package/src/config/index.ts +11 -4
  45. package/src/config/validation-helpers.ts +96 -7
  46. package/src/config/validation.ts +407 -79
  47. package/src/config-cache.ts +45 -0
  48. package/src/create-worker-preview.ts +22 -13
  49. package/src/create-worker-upload-form.ts +32 -9
  50. package/src/dev/dev-vars.ts +36 -0
  51. package/src/dev/dev.tsx +132 -78
  52. package/src/dev/local.tsx +115 -29
  53. package/src/dev/remote.tsx +23 -13
  54. package/src/dev/use-esbuild.ts +23 -5
  55. package/src/dialogs.tsx +16 -6
  56. package/src/entry.ts +83 -24
  57. package/src/environment-variables.ts +3 -1
  58. package/src/errors.ts +11 -0
  59. package/src/https-options.ts +3 -2
  60. package/src/index.tsx +619 -377
  61. package/src/inspect.ts +17 -11
  62. package/src/intl-polyfill.d.ts +139 -0
  63. package/src/logger.ts +66 -0
  64. package/src/miniflare-cli/index.ts +4 -0
  65. package/src/miniflare-cli/request-context.ts +40 -0
  66. package/src/module-collection.ts +7 -7
  67. package/src/open-in-browser.ts +5 -4
  68. package/src/package-manager.ts +9 -8
  69. package/src/pages.tsx +883 -62
  70. package/src/parse.ts +1 -1
  71. package/src/proxy.ts +25 -11
  72. package/src/publish.ts +263 -141
  73. package/src/sites.tsx +27 -14
  74. package/src/tail/index.ts +2 -2
  75. package/src/tail/printing.ts +13 -8
  76. package/src/update-check.ts +19 -0
  77. package/src/user.tsx +116 -41
  78. package/src/whoami.tsx +2 -1
  79. package/src/worker.ts +15 -6
  80. package/templates/gitignore +171 -0
  81. package/templates/static-asset-facade.js +1 -1
  82. package/wrangler-dist/cli.js +21167 -50229
  83. package/miniflare-dist/index.mjs.map +0 -7
  84. package/src/__tests__/dev2.test.tsx +0 -154
  85. package/src/__tests__/logout.test.ts +0 -52
  86. package/src/__tests__/sentry.test.ts +0 -146
  87. package/src/reporting.ts +0 -131
  88. package/wrangler-dist/cli.js.map +0 -7
@@ -1,14 +1,18 @@
1
1
  import path from "node:path";
2
2
  import { normalizeAndValidateConfig } from "../config/validation";
3
- import type { RawConfig, RawEnvironment } from "../config";
3
+ import { normalizeSlashes } from "./helpers/mock-console";
4
+ import type {
5
+ ConfigFields,
6
+ RawDevConfig,
7
+ RawConfig,
8
+ RawEnvironment,
9
+ } from "../config";
4
10
 
5
11
  describe("normalizeAndValidateConfig()", () => {
6
12
  it("should use defaults for empty configuration", () => {
7
- const { config, diagnostics } = normalizeAndValidateConfig(
8
- {},
9
- undefined,
10
- undefined
11
- );
13
+ const { config, diagnostics } = normalizeAndValidateConfig({}, undefined, {
14
+ env: undefined,
15
+ });
12
16
 
13
17
  expect(config).toEqual({
14
18
  account_id: undefined,
@@ -32,6 +36,7 @@ describe("normalizeAndValidateConfig()", () => {
32
36
  },
33
37
  jsx_factory: "React.createElement",
34
38
  jsx_fragment: "React.Fragment",
39
+ tsconfig: undefined,
35
40
  kv_namespaces: [],
36
41
  legacy_env: true,
37
42
  main: undefined,
@@ -52,7 +57,8 @@ describe("normalizeAndValidateConfig()", () => {
52
57
  usage_model: undefined,
53
58
  vars: {},
54
59
  wasm_modules: undefined,
55
- workers_dev: true,
60
+ data_blobs: undefined,
61
+ workers_dev: undefined,
56
62
  zone_id: undefined,
57
63
  });
58
64
  expect(diagnostics.hasErrors()).toBe(false);
@@ -61,9 +67,7 @@ describe("normalizeAndValidateConfig()", () => {
61
67
 
62
68
  describe("top-level non-environment configuration", () => {
63
69
  it("should override config defaults with provided values", () => {
64
- const main = "src/index.ts";
65
- const expectedConfig: RawConfig = {
66
- main,
70
+ const expectedConfig: Partial<ConfigFields<RawDevConfig>> = {
67
71
  legacy_env: true,
68
72
  dev: {
69
73
  ip: "255.255.255.255",
@@ -71,30 +75,21 @@ describe("normalizeAndValidateConfig()", () => {
71
75
  local_protocol: "https",
72
76
  upstream_protocol: "http",
73
77
  },
74
- build: {
75
- command: "COMMAND",
76
- cwd: "CWD",
77
- watch_dir: "WATCH_DIR",
78
- },
79
78
  };
80
79
 
81
80
  const { config, diagnostics } = normalizeAndValidateConfig(
82
81
  expectedConfig,
83
82
  undefined,
84
- undefined
83
+ { env: undefined }
85
84
  );
86
85
 
87
- const resolvedMain = path.resolve(process.cwd(), main);
88
- expect(config).toEqual(
89
- expect.objectContaining({ ...expectedConfig, main: resolvedMain })
90
- );
86
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
91
87
  expect(diagnostics.hasErrors()).toBe(false);
92
88
  expect(diagnostics.hasWarnings()).toBe(false);
93
89
  });
94
90
 
95
91
  it("should error on invalid top level fields", () => {
96
92
  const expectedConfig = {
97
- main: 111,
98
93
  legacy_env: "FOO",
99
94
  dev: {
100
95
  ip: 222,
@@ -102,17 +97,12 @@ describe("normalizeAndValidateConfig()", () => {
102
97
  local_protocol: "wss",
103
98
  upstream_protocol: "ws",
104
99
  },
105
- build: {
106
- command: 555,
107
- cwd: 666,
108
- watch_dir: 777,
109
- },
110
100
  };
111
101
 
112
102
  const { config, diagnostics } = normalizeAndValidateConfig(
113
103
  expectedConfig as unknown as RawConfig,
114
104
  undefined,
115
- undefined
105
+ { env: undefined }
116
106
  );
117
107
 
118
108
  expect(config).toEqual(
@@ -121,11 +111,7 @@ describe("normalizeAndValidateConfig()", () => {
121
111
  expect(diagnostics.hasWarnings()).toBe(false);
122
112
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
123
113
  "Processing wrangler configuration:
124
- - Expected \\"build.command\\" to be of type string but got 555.
125
- - Expected \\"build.cwd\\" to be of type string but got 666.
126
- - Expected \\"build.watch_dir\\" to be of type string but got 777.
127
114
  - Expected \\"legacy_env\\" to be of type boolean but got \\"FOO\\".
128
- - Expected \\"main\\" to be of type string but got 111.
129
115
  - Expected \\"dev.ip\\" to be of type string but got 222.
130
116
  - Expected \\"dev.port\\" to be of type number but got \\"FOO\\".
131
117
  - Expected \\"dev.local_protocol\\" field to be one of [\\"http\\",\\"https\\"] but got \\"wss\\".
@@ -143,7 +129,7 @@ describe("normalizeAndValidateConfig()", () => {
143
129
  const { config, diagnostics } = normalizeAndValidateConfig(
144
130
  expectedConfig as unknown as RawConfig,
145
131
  undefined,
146
- undefined
132
+ { env: undefined }
147
133
  );
148
134
 
149
135
  expect("unexpected" in config).toBe(false);
@@ -154,7 +140,7 @@ describe("normalizeAndValidateConfig()", () => {
154
140
  `);
155
141
  });
156
142
 
157
- it("should ignore `miniflare` top level fields", () => {
143
+ it("should report a deprecation warning if `miniflare` appears at the top level", () => {
158
144
  const expectedConfig = {
159
145
  miniflare: {
160
146
  host: "localhost",
@@ -164,111 +150,18 @@ describe("normalizeAndValidateConfig()", () => {
164
150
  const { config, diagnostics } = normalizeAndValidateConfig(
165
151
  expectedConfig as unknown as RawConfig,
166
152
  undefined,
167
- undefined
153
+ { env: undefined }
168
154
  );
169
155
 
170
156
  expect("miniflare" in config).toBe(false);
171
157
  expect(diagnostics.hasErrors()).toBe(false);
172
158
  expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
173
159
  "Processing wrangler configuration:
174
- "
175
- `);
176
- });
177
-
178
- it("should override build.upload config defaults with provided values and warn about deprecations", () => {
179
- const expectedConfig: RawConfig = {
180
- build: {
181
- upload: {
182
- dir: "src",
183
- format: "modules",
184
- main: "index.ts",
185
- rules: [{ type: "Text", globs: ["GLOB"], fallthrough: true }],
186
- },
187
- },
188
- };
189
-
190
- const { config, diagnostics } = normalizeAndValidateConfig(
191
- expectedConfig,
192
- path.resolve("project/wrangler.toml"),
193
- undefined
194
- );
195
-
196
- expect(config.main).toEqual(path.resolve("project/src/index.ts"));
197
- expect(config.build.upload).toBeUndefined();
198
- expect(diagnostics.hasErrors()).toBe(false);
199
- expect(diagnostics.hasWarnings()).toBe(true);
200
- expect(normalizePath(diagnostics.renderWarnings()))
201
- .toMatchInlineSnapshot(`
202
- "Processing project/wrangler.toml configuration:
203
- - DEPRECATION: \\"build.upload.format\\":
204
- The format is inferred automatically from the code.
205
- - DEPRECATION: \\"build.upload.main\\":
206
- Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
207
- Then add the top level \`main\` field to your configuration file:
208
- \`\`\`
209
- main = \\"src/index.ts\\"
210
- \`\`\`
211
- - DEPRECATION: \\"build.upload.dir\\":
212
- Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the Worker.
213
- - DEPRECATION: The \`build.upload.rules\` config field is no longer used, the rules should be specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration file, and add this:
214
- \`\`\`
215
- [[rules]]
216
- type = \\"Text\\"
217
- globs = [ \\"GLOB\\" ]
218
- fallthrough = true
219
- \`\`\`"
160
+ - 😶 Ignored: \\"miniflare\\":
161
+ Wrangler does not use configuration in the \`miniflare\` section. Unless you are using Miniflare directly you can remove this section."
220
162
  `);
221
163
  });
222
164
 
223
- it("should default custom build watch directories to src", () => {
224
- const expectedConfig: RawConfig = {
225
- build: {
226
- command: "execute some --build",
227
- },
228
- };
229
-
230
- const { config, diagnostics } = normalizeAndValidateConfig(
231
- expectedConfig,
232
- undefined,
233
- undefined
234
- );
235
-
236
- expect(config.build).toEqual(
237
- expect.objectContaining({
238
- command: "execute some --build",
239
- watch_dir: "./src",
240
- })
241
- );
242
-
243
- expect(diagnostics.hasErrors()).toBe(false);
244
- expect(diagnostics.hasWarnings()).toBe(false);
245
- });
246
-
247
- it("should resolve custom build watch directories relative to wrangler.toml", async () => {
248
- const expectedConfig: RawConfig = {
249
- build: {
250
- command: "execute some --build",
251
- watch_dir: "some/path",
252
- },
253
- };
254
-
255
- const { config, diagnostics } = normalizeAndValidateConfig(
256
- expectedConfig,
257
- "project/wrangler.toml",
258
- undefined
259
- );
260
-
261
- expect(config.build).toEqual(
262
- expect.objectContaining({
263
- command: "execute some --build",
264
- watch_dir: path.normalize("project/some/path"),
265
- })
266
- );
267
-
268
- expect(diagnostics.hasErrors()).toBe(false);
269
- expect(diagnostics.hasWarnings()).toBe(false);
270
- });
271
-
272
165
  it("should override `migrations` config defaults with provided values", () => {
273
166
  const expectedConfig: RawConfig = {
274
167
  migrations: [
@@ -289,7 +182,7 @@ describe("normalizeAndValidateConfig()", () => {
289
182
  const { config, diagnostics } = normalizeAndValidateConfig(
290
183
  expectedConfig,
291
184
  undefined,
292
- undefined
185
+ { env: undefined }
293
186
  );
294
187
 
295
188
  expect(config).toEqual(expect.objectContaining(expectedConfig));
@@ -317,7 +210,7 @@ describe("normalizeAndValidateConfig()", () => {
317
210
  const { config, diagnostics } = normalizeAndValidateConfig(
318
211
  expectedConfig as unknown as RawConfig,
319
212
  undefined,
320
- undefined
213
+ { env: undefined }
321
214
  );
322
215
 
323
216
  expect(config).toEqual(expect.objectContaining(expectedConfig));
@@ -338,26 +231,38 @@ describe("normalizeAndValidateConfig()", () => {
338
231
  const expectedConfig: RawConfig = {
339
232
  site: {
340
233
  bucket: "BUCKET",
341
- include: ["INCLUDE_1", "INCLUDE_2"],
234
+ "entry-point": "my-site",
342
235
  exclude: ["EXCLUDE_1", "EXCLUDE_2"],
236
+ include: ["INCLUDE_1", "INCLUDE_2"],
343
237
  },
344
238
  };
345
239
 
346
240
  const { config, diagnostics } = normalizeAndValidateConfig(
347
241
  expectedConfig,
348
242
  undefined,
349
- undefined
243
+ { env: undefined }
350
244
  );
351
245
 
352
246
  expect(config).toEqual(expect.objectContaining(expectedConfig));
353
247
  expect(diagnostics.hasErrors()).toBe(false);
354
- expect(diagnostics.hasWarnings()).toBe(false);
248
+ expect(diagnostics.hasWarnings()).toBe(true);
249
+
250
+ expect(normalizeSlashes(diagnostics.renderWarnings()))
251
+ .toMatchInlineSnapshot(`
252
+ "Processing wrangler configuration:
253
+ - Deprecation: \\"site.entry-point\\":
254
+ Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
255
+ \`\`\`
256
+ main = \\"my-site/index.js\\"
257
+ \`\`\`"
258
+ `);
355
259
  });
356
260
 
357
261
  it("should error if `site` config is missing `bucket`", () => {
358
262
  const expectedConfig: RawConfig = {
359
263
  // @ts-expect-error we're intentionally passing an invalid configuration here
360
264
  site: {
265
+ "entry-point": "workers-site",
361
266
  include: ["INCLUDE_1", "INCLUDE_2"],
362
267
  exclude: ["EXCLUDE_1", "EXCLUDE_2"],
363
268
  },
@@ -366,22 +271,34 @@ describe("normalizeAndValidateConfig()", () => {
366
271
  const { config, diagnostics } = normalizeAndValidateConfig(
367
272
  expectedConfig,
368
273
  undefined,
369
- undefined
274
+ { env: undefined }
370
275
  );
371
276
 
372
277
  expect(config).toEqual(expect.objectContaining(expectedConfig));
278
+ expect(diagnostics.hasWarnings()).toBe(true);
373
279
  expect(diagnostics.hasErrors()).toBe(true);
280
+
281
+ expect(normalizeSlashes(diagnostics.renderWarnings()))
282
+ .toMatchInlineSnapshot(`
283
+ "Processing wrangler configuration:
284
+ - Deprecation: \\"site.entry-point\\":
285
+ Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
286
+ \`\`\`
287
+ main = \\"workers-site/index.js\\"
288
+ \`\`\`"
289
+ `);
290
+
374
291
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
375
292
  "Processing wrangler configuration:
376
293
  - \\"site.bucket\\" is a required field."
377
294
  `);
378
- expect(diagnostics.hasWarnings()).toBe(false);
379
295
  });
380
296
 
381
297
  it("should error on invalid `site` values", () => {
382
298
  const expectedConfig = {
383
299
  site: {
384
300
  bucket: "BUCKET",
301
+ "entry-point": 111,
385
302
  include: [222, 333],
386
303
  exclude: [444, 555],
387
304
  },
@@ -390,21 +307,32 @@ describe("normalizeAndValidateConfig()", () => {
390
307
  const { config, diagnostics } = normalizeAndValidateConfig(
391
308
  expectedConfig as unknown as RawConfig,
392
309
  undefined,
393
- undefined
310
+ { env: undefined }
394
311
  );
395
312
 
396
313
  expect(config).toEqual(expect.objectContaining(expectedConfig));
397
- expect(diagnostics.hasWarnings()).toBe(false);
314
+ expect(diagnostics.hasWarnings()).toBe(true);
398
315
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
399
316
  "Processing wrangler configuration:
400
317
  - Expected \\"sites.include.[0]\\" to be of type string but got 222.
401
318
  - Expected \\"sites.include.[1]\\" to be of type string but got 333.
402
319
  - Expected \\"sites.exclude.[0]\\" to be of type string but got 444.
403
- - Expected \\"sites.exclude.[1]\\" to be of type string but got 555."
320
+ - Expected \\"sites.exclude.[1]\\" to be of type string but got 555.
321
+ - Expected \\"site.entry-point\\" to be of type string but got 111."
322
+ `);
323
+
324
+ expect(normalizeSlashes(diagnostics.renderWarnings()))
325
+ .toMatchInlineSnapshot(`
326
+ "Processing wrangler configuration:
327
+ - Deprecation: \\"site.entry-point\\":
328
+ Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
329
+ \`\`\`
330
+ main = \\"111/index.js\\"
331
+ \`\`\`"
404
332
  `);
405
333
  });
406
334
 
407
- it("should error with a deprecation warning if entry-point is defined", async () => {
335
+ it("should log a deprecation warning if entry-point is defined", async () => {
408
336
  const { config, diagnostics } = normalizeAndValidateConfig(
409
337
  {
410
338
  site: {
@@ -413,27 +341,28 @@ describe("normalizeAndValidateConfig()", () => {
413
341
  },
414
342
  } as unknown as RawConfig,
415
343
  undefined,
416
- undefined
344
+ { env: undefined }
417
345
  );
418
346
 
419
347
  expect(config.site).toMatchInlineSnapshot(`
420
348
  Object {
421
349
  "bucket": "some/path",
350
+ "entry-point": "some/other/script.js",
422
351
  "exclude": Array [],
423
352
  "include": Array [],
424
353
  }
425
354
  `);
426
355
  expect(diagnostics.hasWarnings()).toBe(true);
427
- expect(diagnostics.hasErrors()).toBe(true);
428
- expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
429
- "Processing wrangler configuration:
430
- - Unexpected fields found in site field: \\"entry-point\\""
431
- `);
432
- expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
356
+ expect(diagnostics.hasErrors()).toBe(false);
357
+
358
+ expect(normalizeSlashes(diagnostics.renderWarnings()))
359
+ .toMatchInlineSnapshot(`
433
360
  "Processing wrangler configuration:
434
- - DEPRECATION: \\"site.entry-point\\":
435
- The \`site.entry-point\` config field is no longer used.
436
- The entry-point should be specified via the command line or the \`main\` config field."
361
+ - Deprecation: \\"site.entry-point\\":
362
+ Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
363
+ \`\`\`
364
+ main = \\"some/other/script.js\\"
365
+ \`\`\`"
437
366
  `);
438
367
  });
439
368
  });
@@ -449,7 +378,7 @@ describe("normalizeAndValidateConfig()", () => {
449
378
  const { config, diagnostics } = normalizeAndValidateConfig(
450
379
  expectedConfig,
451
380
  "project/wrangler.toml",
452
- undefined
381
+ { env: undefined }
453
382
  );
454
383
 
455
384
  expect(config).toEqual(
@@ -464,7 +393,7 @@ describe("normalizeAndValidateConfig()", () => {
464
393
  expect(diagnostics.hasWarnings()).toBe(false);
465
394
  });
466
395
 
467
- it("should error on invalid `wasm_module` paths", () => {
396
+ it("should error on invalid `wasm_modules` paths", () => {
468
397
  const expectedConfig = {
469
398
  wasm_modules: {
470
399
  MODULE_1: 111,
@@ -475,7 +404,7 @@ describe("normalizeAndValidateConfig()", () => {
475
404
  const { config, diagnostics } = normalizeAndValidateConfig(
476
405
  expectedConfig as unknown as RawConfig,
477
406
  "project/wrangler.toml",
478
- undefined
407
+ { env: undefined }
479
408
  );
480
409
 
481
410
  expect(config).toEqual(
@@ -502,7 +431,7 @@ describe("normalizeAndValidateConfig()", () => {
502
431
  const { config, diagnostics } = normalizeAndValidateConfig(
503
432
  expectedConfig,
504
433
  "project/wrangler.toml",
505
- undefined
434
+ { env: undefined }
506
435
  );
507
436
 
508
437
  expect(config).toEqual(
@@ -528,7 +457,7 @@ describe("normalizeAndValidateConfig()", () => {
528
457
  const { config, diagnostics } = normalizeAndValidateConfig(
529
458
  expectedConfig as unknown as RawConfig,
530
459
  "project/wrangler.toml",
531
- undefined
460
+ { env: undefined }
532
461
  );
533
462
 
534
463
  expect(config).toEqual(
@@ -544,6 +473,80 @@ describe("normalizeAndValidateConfig()", () => {
544
473
  `);
545
474
  });
546
475
 
476
+ it("should map `data_blobs` paths from relative to the config path to relative to the cwd", () => {
477
+ const expectedConfig: RawConfig = {
478
+ data_blobs: {
479
+ BLOB_1: "path/to/data1.bin",
480
+ BLOB_2: "data2.bin",
481
+ },
482
+ };
483
+
484
+ const { config, diagnostics } = normalizeAndValidateConfig(
485
+ expectedConfig,
486
+ "project/wrangler.toml",
487
+ { env: undefined }
488
+ );
489
+
490
+ expect(config).toEqual(
491
+ expect.objectContaining({
492
+ data_blobs: {
493
+ BLOB_1: path.normalize("project/path/to/data1.bin"),
494
+ BLOB_2: path.normalize("project/data2.bin"),
495
+ },
496
+ })
497
+ );
498
+ expect(diagnostics.hasErrors()).toBe(false);
499
+ expect(diagnostics.hasWarnings()).toBe(false);
500
+ });
501
+
502
+ it("should error on invalid `data_blob` paths", () => {
503
+ const expectedConfig = {
504
+ data_blobs: {
505
+ MODULE_1: 111,
506
+ MODULE_2: 222,
507
+ },
508
+ };
509
+
510
+ const { config, diagnostics } = normalizeAndValidateConfig(
511
+ expectedConfig as unknown as RawConfig,
512
+ "project/wrangler.toml",
513
+ { env: undefined }
514
+ );
515
+
516
+ expect(config).toEqual(
517
+ expect.objectContaining({
518
+ data_blobs: {},
519
+ })
520
+ );
521
+ expect(diagnostics.hasWarnings()).toBe(false);
522
+ expect(normalizePath(diagnostics.renderErrors())).toMatchInlineSnapshot(`
523
+ "Processing project/wrangler.toml configuration:
524
+ - Expected \\"data_blobs['MODULE_1']\\" to be of type string but got 111.
525
+ - Expected \\"data_blobs['MODULE_2']\\" to be of type string but got 222."
526
+ `);
527
+ });
528
+
529
+ it("should resolve tsconfig relative to wrangler.toml", async () => {
530
+ const expectedConfig: RawEnvironment = {
531
+ tsconfig: "path/to/some-tsconfig.json",
532
+ };
533
+
534
+ const { config, diagnostics } = normalizeAndValidateConfig(
535
+ expectedConfig,
536
+ "project/wrangler.toml",
537
+ { env: undefined }
538
+ );
539
+
540
+ expect(config).toEqual(
541
+ expect.objectContaining({
542
+ tsconfig: path.normalize("project/path/to/some-tsconfig.json"),
543
+ })
544
+ );
545
+
546
+ expect(diagnostics.hasErrors()).toBe(false);
547
+ expect(diagnostics.hasWarnings()).toBe(false);
548
+ });
549
+
547
550
  describe("(deprecated)", () => {
548
551
  it("should remove and warn about deprecated properties", () => {
549
552
  const rawConfig: RawConfig = {
@@ -554,7 +557,7 @@ describe("normalizeAndValidateConfig()", () => {
554
557
  const { config, diagnostics } = normalizeAndValidateConfig(
555
558
  rawConfig,
556
559
  undefined,
557
- undefined
560
+ { env: undefined }
558
561
  );
559
562
 
560
563
  // Note the `.not.` here...
@@ -567,29 +570,44 @@ describe("normalizeAndValidateConfig()", () => {
567
570
  expect(diagnostics.hasErrors()).toBe(false);
568
571
  expect(diagnostics.hasWarnings()).toBe(true);
569
572
  expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
570
- "Processing wrangler configuration:
571
- - DEPRECATION: \\"type\\":
572
- DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
573
- - DEPRECATION: \\"webpack_config\\":
574
- DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build."
575
- `);
573
+ "Processing wrangler configuration:
574
+ - 😶 Ignored: \\"type\\":
575
+ Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
576
+ - 😶 Ignored: \\"webpack_config\\":
577
+ Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build."
578
+ `);
576
579
  });
577
580
  });
578
581
  });
579
582
 
580
583
  describe("top-level environment configuration", () => {
581
584
  it("should override config defaults with provided values", () => {
582
- const expectedConfig: RawConfig = {
583
- name: "NAME",
585
+ const main = "src/index.ts";
586
+ const resolvedMain = path.resolve(process.cwd(), main);
587
+
588
+ const expectedConfig: RawEnvironment = {
589
+ name: "mock-name",
584
590
  account_id: "ACCOUNT_ID",
585
591
  compatibility_date: "2022-01-01",
586
592
  compatibility_flags: ["FLAG1", "FLAG2"],
587
593
  workers_dev: false,
588
- routes: ["ROUTE_1", "ROUTE_2"],
594
+ routes: [
595
+ "ROUTE_1",
596
+ "ROUTE_2",
597
+ { pattern: "ROUTE3", zone_id: "ZONE_ID_3" },
598
+ "ROUTE_4",
599
+ ],
589
600
  jsx_factory: "JSX_FACTORY",
590
601
  jsx_fragment: "JSX_FRAGMENT",
602
+ tsconfig: "path/to/tsconfig",
591
603
  triggers: { crons: ["CRON_1", "CRON_2"] },
592
604
  usage_model: "bundled",
605
+ main,
606
+ build: {
607
+ command: "COMMAND",
608
+ cwd: "CWD",
609
+ watch_dir: "WATCH_DIR",
610
+ },
593
611
  vars: {
594
612
  VAR1: "VALUE_1",
595
613
  VAR2: "VALUE_2",
@@ -635,10 +653,12 @@ describe("normalizeAndValidateConfig()", () => {
635
653
  const { config, diagnostics } = normalizeAndValidateConfig(
636
654
  expectedConfig,
637
655
  undefined,
638
- undefined
656
+ { env: undefined }
639
657
  );
640
658
 
641
- expect(config).toEqual(expect.objectContaining(expectedConfig));
659
+ expect(config).toEqual(
660
+ expect.objectContaining({ ...expectedConfig, main: resolvedMain })
661
+ );
642
662
  expect(diagnostics.hasErrors()).toBe(false);
643
663
  expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
644
664
  "Processing wrangler configuration:
@@ -647,50 +667,283 @@ describe("normalizeAndValidateConfig()", () => {
647
667
  });
648
668
 
649
669
  it("should error on invalid environment values", () => {
650
- const expectedConfig: RawConfig = {
670
+ const expectedConfig: RawEnvironment = {
651
671
  name: 111,
652
672
  account_id: 222,
653
673
  compatibility_date: 333,
654
674
  compatibility_flags: [444, 555],
655
675
  workers_dev: "BAD",
656
- routes: [666, 777],
676
+ routes: [
677
+ 666,
678
+ 777,
679
+ // this one's valid, but we add it here to make sure
680
+ // it doesn't get included in the error message
681
+ "example.com/*",
682
+ { pattern: 123, zone_id: "zone_id_1" },
683
+ { pattern: "route_2", zone_id: 123 },
684
+ { pattern: "route_2", zone_name: 123 },
685
+ { pattern: "route_3" },
686
+ { zone_id: "zone_id_4" },
687
+ { zone_name: "zone_name_4" },
688
+ { pattern: undefined },
689
+ { pattern: "route_5", zone_id: "zone_id_5", some_other_key: 123 },
690
+ { pattern: "route_5", zone_name: "zone_name_5", some_other_key: 123 },
691
+ // this one's valid too
692
+ { pattern: "route_6", zone_id: "zone_id_6" },
693
+ // as well as this one
694
+ { pattern: "route_6", zone_name: "zone_name_6" },
695
+ ],
657
696
  route: 888,
658
697
  jsx_factory: 999,
659
698
  jsx_fragment: 1000,
699
+ tsconfig: true,
660
700
  triggers: { crons: [1111, 1222] },
661
701
  usage_model: "INVALID",
662
- } as unknown as RawConfig;
702
+ main: 1333,
703
+ build: {
704
+ command: 1444,
705
+ cwd: 1555,
706
+ watch_dir: 1666,
707
+ },
708
+ } as unknown as RawEnvironment;
663
709
 
664
710
  const { config, diagnostics } = normalizeAndValidateConfig(
665
711
  expectedConfig,
666
712
  undefined,
667
- undefined
713
+ { env: undefined }
668
714
  );
669
715
 
670
716
  expect(config).toEqual(expect.objectContaining(expectedConfig));
671
717
  expect(diagnostics.hasWarnings()).toBe(false);
672
718
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
673
719
  "Processing wrangler configuration:
674
- - Expected \\"route\\" to be of type string but got 888.
675
- - Expected \\"routes\\" to be of type string array but got [666,777].
720
+ - Expected \\"route\\" to be either a string, or an object with shape { pattern, zone_id | zone_name }, but got 888.
721
+ - Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, zone_id | zone_name }, but these weren't valid: [
722
+ 666,
723
+ 777,
724
+ {
725
+ \\"pattern\\": 123,
726
+ \\"zone_id\\": \\"zone_id_1\\"
727
+ },
728
+ {
729
+ \\"pattern\\": \\"route_2\\",
730
+ \\"zone_id\\": 123
731
+ },
732
+ {
733
+ \\"pattern\\": \\"route_2\\",
734
+ \\"zone_name\\": 123
735
+ },
736
+ {
737
+ \\"pattern\\": \\"route_3\\"
738
+ },
739
+ {
740
+ \\"zone_id\\": \\"zone_id_4\\"
741
+ },
742
+ {
743
+ \\"zone_name\\": \\"zone_name_4\\"
744
+ },
745
+ {},
746
+ {
747
+ \\"pattern\\": \\"route_5\\",
748
+ \\"zone_id\\": \\"zone_id_5\\",
749
+ \\"some_other_key\\": 123
750
+ },
751
+ {
752
+ \\"pattern\\": \\"route_5\\",
753
+ \\"zone_name\\": \\"zone_name_5\\",
754
+ \\"some_other_key\\": 123
755
+ }
756
+ ].
676
757
  - Expected exactly one of the following fields [\\"routes\\",\\"route\\"].
677
758
  - Expected \\"workers_dev\\" to be of type boolean but got \\"BAD\\".
759
+ - Expected \\"build.command\\" to be of type string but got 1444.
760
+ - Expected \\"build.cwd\\" to be of type string but got 1555.
761
+ - Expected \\"build.watch_dir\\" to be of type string but got 1666.
678
762
  - Expected \\"account_id\\" to be of type string but got 222.
679
763
  - Expected \\"compatibility_date\\" to be of type string but got 333.
680
764
  - Expected \\"compatibility_flags\\" to be of type string array but got [444,555].
681
765
  - Expected \\"jsx_factory\\" to be of type string but got 999.
682
766
  - Expected \\"jsx_fragment\\" to be of type string but got 1000.
683
- - Expected \\"name\\" to be of type string but got 111.
767
+ - Expected \\"tsconfig\\" to be of type string but got true.
768
+ - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
769
+ - Expected \\"main\\" to be of type string but got 1333.
684
770
  - Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
685
771
  `);
686
772
  });
687
773
 
774
+ it("should error on invalid `name` value with spaces", () => {
775
+ const expectedConfig: RawEnvironment = {
776
+ name: "NCC 1701 D",
777
+ } as unknown as RawEnvironment;
778
+
779
+ const { config, diagnostics } = normalizeAndValidateConfig(
780
+ expectedConfig,
781
+ undefined,
782
+ { env: undefined }
783
+ );
784
+
785
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
786
+ expect(diagnostics.hasWarnings()).toBe(false);
787
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
788
+ "Processing wrangler configuration:
789
+ - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"NCC 1701 D\\"."
790
+ `);
791
+ });
792
+
793
+ it("should be valid `name` with underscores", () => {
794
+ const expectedConfig: RawEnvironment = {
795
+ name: "enterprise_nx_01",
796
+ } as unknown as RawEnvironment;
797
+
798
+ const { config, diagnostics } = normalizeAndValidateConfig(
799
+ expectedConfig,
800
+ undefined,
801
+ { env: undefined }
802
+ );
803
+
804
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
805
+ expect(diagnostics.hasWarnings()).toBe(false);
806
+ expect(diagnostics.hasErrors()).toBe(false);
807
+ });
808
+
809
+ it("should error on invalid `name` value with special characters", () => {
810
+ const expectedConfig: RawEnvironment = {
811
+ name: "Thy'lek-Shran",
812
+ } as unknown as RawEnvironment;
813
+
814
+ const { config, diagnostics } = normalizeAndValidateConfig(
815
+ expectedConfig,
816
+ undefined,
817
+ { env: undefined }
818
+ );
819
+
820
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
821
+ expect(diagnostics.hasWarnings()).toBe(false);
822
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
823
+ "Processing wrangler configuration:
824
+ - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"Thy'lek-Shran\\"."
825
+ `);
826
+ });
827
+
828
+ it("should error on invalid `name` value with only special characters", () => {
829
+ const expectedConfig: RawEnvironment = {
830
+ name: "!@#$%^&*(()",
831
+ } as unknown as RawEnvironment;
832
+
833
+ const { config, diagnostics } = normalizeAndValidateConfig(
834
+ expectedConfig,
835
+ undefined,
836
+ { env: undefined }
837
+ );
838
+
839
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
840
+ expect(diagnostics.hasWarnings()).toBe(false);
841
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
842
+ "Processing wrangler configuration:
843
+ - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"!@#$%^&*(()\\"."
844
+ `);
845
+ });
846
+
847
+ it("should override build.upload config defaults with provided values and warn about deprecations", () => {
848
+ const expectedConfig: RawEnvironment = {
849
+ build: {
850
+ upload: {
851
+ dir: "src",
852
+ format: "modules",
853
+ main: "index.ts",
854
+ rules: [{ type: "Text", globs: ["GLOB"], fallthrough: true }],
855
+ },
856
+ },
857
+ };
858
+
859
+ const { config, diagnostics } = normalizeAndValidateConfig(
860
+ expectedConfig,
861
+ path.resolve("project/wrangler.toml"),
862
+ { env: undefined }
863
+ );
864
+
865
+ expect(config.main).toEqual(path.resolve("project/src/index.ts"));
866
+ expect(config.build.upload).toBeUndefined();
867
+ expect(diagnostics.hasErrors()).toBe(false);
868
+ expect(diagnostics.hasWarnings()).toBe(true);
869
+ expect(normalizePath(diagnostics.renderWarnings()))
870
+ .toMatchInlineSnapshot(`
871
+ "Processing project/wrangler.toml configuration:
872
+ - Deprecation: \\"build.upload.format\\":
873
+ The format is inferred automatically from the code.
874
+ - Deprecation: \\"build.upload.main\\":
875
+ Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
876
+ Then add the top level \`main\` field to your configuration file:
877
+ \`\`\`
878
+ main = \\"src/index.ts\\"
879
+ \`\`\`
880
+ - Deprecation: \\"build.upload.dir\\":
881
+ Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the Worker.
882
+ - Deprecation: The \`build.upload.rules\` config field is no longer used, the rules should be specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration file, and add this:
883
+ \`\`\`
884
+ [[rules]]
885
+ type = \\"Text\\"
886
+ globs = [ \\"GLOB\\" ]
887
+ fallthrough = true
888
+ \`\`\`"
889
+ `);
890
+ });
891
+
892
+ it("should default custom build watch directories to src", () => {
893
+ const expectedConfig: RawEnvironment = {
894
+ build: {
895
+ command: "execute some --build",
896
+ },
897
+ };
898
+
899
+ const { config, diagnostics } = normalizeAndValidateConfig(
900
+ expectedConfig,
901
+ undefined,
902
+ { env: undefined }
903
+ );
904
+
905
+ expect(config.build).toEqual(
906
+ expect.objectContaining({
907
+ command: "execute some --build",
908
+ watch_dir: "./src",
909
+ })
910
+ );
911
+
912
+ expect(diagnostics.hasErrors()).toBe(false);
913
+ expect(diagnostics.hasWarnings()).toBe(false);
914
+ });
915
+
916
+ it("should resolve custom build watch directories relative to wrangler.toml", async () => {
917
+ const expectedConfig: RawEnvironment = {
918
+ build: {
919
+ command: "execute some --build",
920
+ watch_dir: "some/path",
921
+ },
922
+ };
923
+
924
+ const { config, diagnostics } = normalizeAndValidateConfig(
925
+ expectedConfig,
926
+ "project/wrangler.toml",
927
+ { env: undefined }
928
+ );
929
+
930
+ expect(config.build).toEqual(
931
+ expect.objectContaining({
932
+ command: "execute some --build",
933
+ watch_dir: path.normalize("project/some/path"),
934
+ })
935
+ );
936
+
937
+ expect(diagnostics.hasErrors()).toBe(false);
938
+ expect(diagnostics.hasWarnings()).toBe(false);
939
+ });
940
+
688
941
  describe("durable_objects field", () => {
689
942
  it("should error if durable_objects is an array", () => {
690
943
  const { config, diagnostics } = normalizeAndValidateConfig(
691
944
  { durable_objects: [] } as unknown as RawConfig,
692
945
  undefined,
693
- undefined
946
+ { env: undefined }
694
947
  );
695
948
 
696
949
  expect(config).toEqual(
@@ -707,7 +960,7 @@ describe("normalizeAndValidateConfig()", () => {
707
960
  const { config, diagnostics } = normalizeAndValidateConfig(
708
961
  { durable_objects: "BAD" } as unknown as RawConfig,
709
962
  undefined,
710
- undefined
963
+ { env: undefined }
711
964
  );
712
965
 
713
966
  expect(config).toEqual(
@@ -724,7 +977,7 @@ describe("normalizeAndValidateConfig()", () => {
724
977
  const { config, diagnostics } = normalizeAndValidateConfig(
725
978
  { durable_objects: 999 } as unknown as RawConfig,
726
979
  undefined,
727
- undefined
980
+ { env: undefined }
728
981
  );
729
982
 
730
983
  expect(config).toEqual(
@@ -741,7 +994,7 @@ describe("normalizeAndValidateConfig()", () => {
741
994
  const { config, diagnostics } = normalizeAndValidateConfig(
742
995
  { durable_objects: null } as unknown as RawConfig,
743
996
  undefined,
744
- undefined
997
+ { env: undefined }
745
998
  );
746
999
 
747
1000
  expect(config).toEqual(
@@ -758,7 +1011,7 @@ describe("normalizeAndValidateConfig()", () => {
758
1011
  const { config, diagnostics } = normalizeAndValidateConfig(
759
1012
  { durable_objects: {} } as unknown as RawConfig,
760
1013
  undefined,
761
- undefined
1014
+ { env: undefined }
762
1015
  );
763
1016
 
764
1017
  expect(config).toEqual(
@@ -775,7 +1028,7 @@ describe("normalizeAndValidateConfig()", () => {
775
1028
  const { config, diagnostics } = normalizeAndValidateConfig(
776
1029
  { durable_objects: { bindings: {} } } as unknown as RawConfig,
777
1030
  undefined,
778
- undefined
1031
+ { env: undefined }
779
1032
  );
780
1033
 
781
1034
  expect(config).toEqual(
@@ -794,7 +1047,7 @@ describe("normalizeAndValidateConfig()", () => {
794
1047
  const { config, diagnostics } = normalizeAndValidateConfig(
795
1048
  { durable_objects: { bindings: "BAD" } } as unknown as RawConfig,
796
1049
  undefined,
797
- undefined
1050
+ { env: undefined }
798
1051
  );
799
1052
 
800
1053
  expect(config).toEqual(
@@ -813,7 +1066,7 @@ describe("normalizeAndValidateConfig()", () => {
813
1066
  const { config, diagnostics } = normalizeAndValidateConfig(
814
1067
  { durable_objects: { bindings: 999 } } as unknown as RawConfig,
815
1068
  undefined,
816
- undefined
1069
+ { env: undefined }
817
1070
  );
818
1071
 
819
1072
  expect(config).toEqual(
@@ -832,7 +1085,7 @@ describe("normalizeAndValidateConfig()", () => {
832
1085
  const { config, diagnostics } = normalizeAndValidateConfig(
833
1086
  { durable_objects: { bindings: null } } as unknown as RawConfig,
834
1087
  undefined,
835
- undefined
1088
+ { env: undefined }
836
1089
  );
837
1090
 
838
1091
  expect(config).toEqual(
@@ -864,7 +1117,7 @@ describe("normalizeAndValidateConfig()", () => {
864
1117
  },
865
1118
  } as unknown as RawConfig,
866
1119
  undefined,
867
- undefined
1120
+ { env: undefined }
868
1121
  );
869
1122
 
870
1123
  expect(config).toEqual(
@@ -900,7 +1153,7 @@ describe("normalizeAndValidateConfig()", () => {
900
1153
  const { config, diagnostics } = normalizeAndValidateConfig(
901
1154
  { kv_namespaces: {} } as unknown as RawConfig,
902
1155
  undefined,
903
- undefined
1156
+ { env: undefined }
904
1157
  );
905
1158
 
906
1159
  expect(config).toEqual(
@@ -917,7 +1170,7 @@ describe("normalizeAndValidateConfig()", () => {
917
1170
  const { config, diagnostics } = normalizeAndValidateConfig(
918
1171
  { kv_namespaces: "BAD" } as unknown as RawConfig,
919
1172
  undefined,
920
- undefined
1173
+ { env: undefined }
921
1174
  );
922
1175
 
923
1176
  expect(config).toEqual(
@@ -934,7 +1187,7 @@ describe("normalizeAndValidateConfig()", () => {
934
1187
  const { config, diagnostics } = normalizeAndValidateConfig(
935
1188
  { kv_namespaces: 999 } as unknown as RawConfig,
936
1189
  undefined,
937
- undefined
1190
+ { env: undefined }
938
1191
  );
939
1192
 
940
1193
  expect(config).toEqual(
@@ -951,7 +1204,7 @@ describe("normalizeAndValidateConfig()", () => {
951
1204
  const { config, diagnostics } = normalizeAndValidateConfig(
952
1205
  { kv_namespaces: null } as unknown as RawConfig,
953
1206
  undefined,
954
- undefined
1207
+ { env: undefined }
955
1208
  );
956
1209
 
957
1210
  expect(config).toEqual(
@@ -979,7 +1232,7 @@ describe("normalizeAndValidateConfig()", () => {
979
1232
  ],
980
1233
  } as unknown as RawConfig,
981
1234
  undefined,
982
- undefined
1235
+ { env: undefined }
983
1236
  );
984
1237
 
985
1238
  expect(config).toEqual(
@@ -1005,7 +1258,7 @@ describe("normalizeAndValidateConfig()", () => {
1005
1258
  const { config, diagnostics } = normalizeAndValidateConfig(
1006
1259
  { r2_buckets: {} } as unknown as RawConfig,
1007
1260
  undefined,
1008
- undefined
1261
+ { env: undefined }
1009
1262
  );
1010
1263
 
1011
1264
  expect(config).toEqual(
@@ -1022,7 +1275,7 @@ describe("normalizeAndValidateConfig()", () => {
1022
1275
  const { config, diagnostics } = normalizeAndValidateConfig(
1023
1276
  { r2_buckets: "BAD" } as unknown as RawConfig,
1024
1277
  undefined,
1025
- undefined
1278
+ { env: undefined }
1026
1279
  );
1027
1280
 
1028
1281
  expect(config).toEqual(
@@ -1039,7 +1292,7 @@ describe("normalizeAndValidateConfig()", () => {
1039
1292
  const { config, diagnostics } = normalizeAndValidateConfig(
1040
1293
  { r2_buckets: 999 } as unknown as RawConfig,
1041
1294
  undefined,
1042
- undefined
1295
+ { env: undefined }
1043
1296
  );
1044
1297
 
1045
1298
  expect(config).toEqual(
@@ -1056,7 +1309,7 @@ describe("normalizeAndValidateConfig()", () => {
1056
1309
  const { config, diagnostics } = normalizeAndValidateConfig(
1057
1310
  { r2_buckets: null } as unknown as RawConfig,
1058
1311
  undefined,
1059
- undefined
1312
+ { env: undefined }
1060
1313
  );
1061
1314
 
1062
1315
  expect(config).toEqual(
@@ -1084,7 +1337,7 @@ describe("normalizeAndValidateConfig()", () => {
1084
1337
  ],
1085
1338
  } as unknown as RawConfig,
1086
1339
  undefined,
1087
- undefined
1340
+ { env: undefined }
1088
1341
  );
1089
1342
 
1090
1343
  expect(config).toEqual(
@@ -1110,7 +1363,7 @@ describe("normalizeAndValidateConfig()", () => {
1110
1363
  const { config, diagnostics } = normalizeAndValidateConfig(
1111
1364
  { unsafe: [] } as unknown as RawConfig,
1112
1365
  undefined,
1113
- undefined
1366
+ { env: undefined }
1114
1367
  );
1115
1368
 
1116
1369
  expect(config).toEqual(
@@ -1130,7 +1383,7 @@ describe("normalizeAndValidateConfig()", () => {
1130
1383
  const { config, diagnostics } = normalizeAndValidateConfig(
1131
1384
  { unsafe: "BAD" } as unknown as RawConfig,
1132
1385
  undefined,
1133
- undefined
1386
+ { env: undefined }
1134
1387
  );
1135
1388
 
1136
1389
  expect(config).toEqual(
@@ -1150,7 +1403,7 @@ describe("normalizeAndValidateConfig()", () => {
1150
1403
  const { config, diagnostics } = normalizeAndValidateConfig(
1151
1404
  { unsafe: 999 } as unknown as RawConfig,
1152
1405
  undefined,
1153
- undefined
1406
+ { env: undefined }
1154
1407
  );
1155
1408
 
1156
1409
  expect(config).toEqual(
@@ -1170,7 +1423,7 @@ describe("normalizeAndValidateConfig()", () => {
1170
1423
  const { config, diagnostics } = normalizeAndValidateConfig(
1171
1424
  { unsafe: null } as unknown as RawConfig,
1172
1425
  undefined,
1173
- undefined
1426
+ { env: undefined }
1174
1427
  );
1175
1428
 
1176
1429
  expect(config).toEqual(
@@ -1190,7 +1443,7 @@ describe("normalizeAndValidateConfig()", () => {
1190
1443
  const { config, diagnostics } = normalizeAndValidateConfig(
1191
1444
  { unsafe: {} } as unknown as RawConfig,
1192
1445
  undefined,
1193
- undefined
1446
+ { env: undefined }
1194
1447
  );
1195
1448
 
1196
1449
  expect(config).toEqual(
@@ -1210,7 +1463,7 @@ describe("normalizeAndValidateConfig()", () => {
1210
1463
  const { config, diagnostics } = normalizeAndValidateConfig(
1211
1464
  { unsafe: { bindings: {} } } as unknown as RawConfig,
1212
1465
  undefined,
1213
- undefined
1466
+ { env: undefined }
1214
1467
  );
1215
1468
 
1216
1469
  expect(config).toEqual(
@@ -1232,7 +1485,7 @@ describe("normalizeAndValidateConfig()", () => {
1232
1485
  const { config, diagnostics } = normalizeAndValidateConfig(
1233
1486
  { unsafe: { bindings: "BAD" } } as unknown as RawConfig,
1234
1487
  undefined,
1235
- undefined
1488
+ { env: undefined }
1236
1489
  );
1237
1490
 
1238
1491
  expect(config).toEqual(
@@ -1254,7 +1507,7 @@ describe("normalizeAndValidateConfig()", () => {
1254
1507
  const { config, diagnostics } = normalizeAndValidateConfig(
1255
1508
  { unsafe: { bindings: 999 } } as unknown as RawConfig,
1256
1509
  undefined,
1257
- undefined
1510
+ { env: undefined }
1258
1511
  );
1259
1512
 
1260
1513
  expect(config).toEqual(
@@ -1276,7 +1529,7 @@ describe("normalizeAndValidateConfig()", () => {
1276
1529
  const { config, diagnostics } = normalizeAndValidateConfig(
1277
1530
  { unsafe: { bindings: null } } as unknown as RawConfig,
1278
1531
  undefined,
1279
- undefined
1532
+ { env: undefined }
1280
1533
  );
1281
1534
 
1282
1535
  expect(config).toEqual(
@@ -1311,7 +1564,7 @@ describe("normalizeAndValidateConfig()", () => {
1311
1564
  },
1312
1565
  } as unknown as RawConfig,
1313
1566
  undefined,
1314
- undefined
1567
+ { env: undefined }
1315
1568
  );
1316
1569
 
1317
1570
  expect(config).toEqual(
@@ -1346,7 +1599,7 @@ describe("normalizeAndValidateConfig()", () => {
1346
1599
  zone_id: "ZONE_ID",
1347
1600
  experimental_services: [
1348
1601
  {
1349
- name: "NAME",
1602
+ name: "mock-name",
1350
1603
  service: "SERVICE",
1351
1604
  environment: "ENV",
1352
1605
  },
@@ -1356,7 +1609,7 @@ describe("normalizeAndValidateConfig()", () => {
1356
1609
  const { config, diagnostics } = normalizeAndValidateConfig(
1357
1610
  rawConfig,
1358
1611
  undefined,
1359
- undefined
1612
+ { env: undefined }
1360
1613
  );
1361
1614
 
1362
1615
  expect("experimental_services" in config).toBe(false);
@@ -1365,19 +1618,19 @@ describe("normalizeAndValidateConfig()", () => {
1365
1618
  expect(diagnostics.hasErrors()).toBe(false);
1366
1619
  expect(diagnostics.hasWarnings()).toBe(true);
1367
1620
  expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1368
- "Processing wrangler configuration:
1369
- - DEPRECATION: \\"zone_id\\":
1370
- This is unnecessary since we can deduce this from routes directly.
1371
- - DEPRECATION: \\"experimental_services\\":
1372
- The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
1373
- \`\`\`
1374
- [[unsafe.bindings]]
1375
- name = \\"NAME\\"
1376
- type = \\"service\\"
1377
- service = \\"SERVICE\\"
1378
- environment = \\"ENV\\"
1379
- \`\`\`"
1380
- `);
1621
+ "Processing wrangler configuration:
1622
+ - Deprecation: \\"zone_id\\":
1623
+ This is unnecessary since we can deduce this from routes directly.
1624
+ - Deprecation: \\"experimental_services\\":
1625
+ The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
1626
+ \`\`\`
1627
+ [[unsafe.bindings]]
1628
+ name = \\"mock-name\\"
1629
+ type = \\"service\\"
1630
+ service = \\"SERVICE\\"
1631
+ environment = \\"ENV\\"
1632
+ \`\`\`"
1633
+ `);
1381
1634
  });
1382
1635
  });
1383
1636
 
@@ -1391,7 +1644,7 @@ describe("normalizeAndValidateConfig()", () => {
1391
1644
  const { diagnostics } = normalizeAndValidateConfig(
1392
1645
  rawConfig,
1393
1646
  undefined,
1394
- undefined
1647
+ { env: undefined }
1395
1648
  );
1396
1649
 
1397
1650
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
@@ -1405,11 +1658,9 @@ describe("normalizeAndValidateConfig()", () => {
1405
1658
  describe("named environments", () => {
1406
1659
  it("should warn if we specify an environment but there are no named environments", () => {
1407
1660
  const rawConfig: RawConfig = {};
1408
- const { diagnostics } = normalizeAndValidateConfig(
1409
- rawConfig,
1410
- undefined,
1411
- "DEV"
1412
- );
1661
+ const { diagnostics } = normalizeAndValidateConfig(rawConfig, undefined, {
1662
+ env: "DEV",
1663
+ });
1413
1664
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1414
1665
  "Processing wrangler configuration:
1415
1666
  "
@@ -1427,13 +1678,11 @@ describe("normalizeAndValidateConfig()", () => {
1427
1678
  `);
1428
1679
  });
1429
1680
 
1430
- it("should warn if we specify an environment that does not match the named environments", () => {
1681
+ it("should error if we specify an environment that does not match the named environments", () => {
1431
1682
  const rawConfig: RawConfig = { env: { ENV1: {} } };
1432
- const { diagnostics } = normalizeAndValidateConfig(
1433
- rawConfig,
1434
- undefined,
1435
- "DEV"
1436
- );
1683
+ const { diagnostics } = normalizeAndValidateConfig(rawConfig, undefined, {
1684
+ env: "DEV",
1685
+ });
1437
1686
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1438
1687
  "Processing wrangler configuration:
1439
1688
  - No environment found in configuration with name \\"DEV\\".
@@ -1453,8 +1702,10 @@ describe("normalizeAndValidateConfig()", () => {
1453
1702
  });
1454
1703
 
1455
1704
  it("should use top-level values for inheritable config fields", () => {
1456
- const expectedConfig: RawConfig = {
1457
- name: "NAME",
1705
+ const main = "src/index.ts";
1706
+ const resolvedMain = path.resolve(process.cwd(), main);
1707
+ const rawConfig: RawConfig = {
1708
+ name: "mock-name",
1458
1709
  account_id: "ACCOUNT_ID",
1459
1710
  compatibility_date: "2022-01-01",
1460
1711
  compatibility_flags: ["FLAG1", "FLAG2"],
@@ -1462,24 +1713,39 @@ describe("normalizeAndValidateConfig()", () => {
1462
1713
  routes: ["ROUTE_1", "ROUTE_2"],
1463
1714
  jsx_factory: "JSX_FACTORY",
1464
1715
  jsx_fragment: "JSX_FRAGMENT",
1716
+ tsconfig: "path/to/tsconfig.json",
1465
1717
  triggers: { crons: ["CRON_1", "CRON_2"] },
1466
1718
  usage_model: "bundled",
1719
+ main,
1720
+ build: {
1721
+ command: "COMMAND",
1722
+ cwd: "CWD",
1723
+ watch_dir: "WATCH_DIR",
1724
+ },
1467
1725
  };
1468
1726
 
1469
1727
  const { config, diagnostics } = normalizeAndValidateConfig(
1470
- { ...expectedConfig, env: { DEV: {} } },
1728
+ { ...rawConfig, env: { dev: {} } },
1471
1729
  undefined,
1472
- "DEV"
1730
+ { env: "dev" }
1473
1731
  );
1474
1732
 
1475
- expect(config).toEqual(expect.objectContaining(expectedConfig));
1733
+ expect(config).toEqual(
1734
+ expect.objectContaining({
1735
+ ...rawConfig,
1736
+ main: resolvedMain,
1737
+ name: "mock-name-dev",
1738
+ })
1739
+ );
1476
1740
  expect(diagnostics.hasErrors()).toBe(false);
1477
1741
  expect(diagnostics.hasWarnings()).toBe(false);
1478
1742
  });
1479
1743
 
1480
1744
  it("should override top-level values for inheritable config fields", () => {
1481
- const environment: RawEnvironment = {
1482
- name: "ENV_NAME",
1745
+ const main = "src/index.ts";
1746
+ const resolvedMain = path.resolve(process.cwd(), main);
1747
+ const rawEnv: RawEnvironment = {
1748
+ name: "mock-env-name",
1483
1749
  account_id: "ENV_ACCOUNT_ID",
1484
1750
  compatibility_date: "2022-02-02",
1485
1751
  compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
@@ -1487,11 +1753,18 @@ describe("normalizeAndValidateConfig()", () => {
1487
1753
  routes: ["ENV_ROUTE_1", "ENV_ROUTE_2"],
1488
1754
  jsx_factory: "ENV_JSX_FACTORY",
1489
1755
  jsx_fragment: "ENV_JSX_FRAGMENT",
1756
+ tsconfig: "ENV_path/to/tsconfig.json",
1490
1757
  triggers: { crons: ["ENV_CRON_1", "ENV_CRON_2"] },
1491
1758
  usage_model: "unbound",
1759
+ main,
1760
+ build: {
1761
+ command: "ENV_COMMAND",
1762
+ cwd: "ENV_CWD",
1763
+ watch_dir: "ENV_WATCH_DIR",
1764
+ },
1492
1765
  };
1493
- const expectedConfig: RawConfig = {
1494
- name: "NAME",
1766
+ const rawConfig: RawConfig = {
1767
+ name: "mock-name",
1495
1768
  account_id: "ACCOUNT_ID",
1496
1769
  compatibility_date: "2022-01-01",
1497
1770
  compatibility_flags: ["FLAG1", "FLAG2"],
@@ -1499,20 +1772,29 @@ describe("normalizeAndValidateConfig()", () => {
1499
1772
  routes: ["ROUTE_1", "ROUTE_2"],
1500
1773
  jsx_factory: "JSX_FACTORY",
1501
1774
  jsx_fragment: "JSX_FRAGMENT",
1775
+ tsconfig: "path/to/tsconfig.json",
1502
1776
  triggers: { crons: ["CRON_1", "CRON_2"] },
1503
1777
  usage_model: "bundled",
1778
+ main: "top-level.js",
1779
+ build: {
1780
+ command: "COMMAND",
1781
+ cwd: "CWD",
1782
+ watch_dir: "WATCH_DIR",
1783
+ },
1504
1784
  env: {
1505
- ENV1: environment,
1785
+ ENV1: rawEnv,
1506
1786
  },
1507
1787
  };
1508
1788
 
1509
1789
  const { config, diagnostics } = normalizeAndValidateConfig(
1510
- expectedConfig,
1790
+ rawConfig,
1511
1791
  undefined,
1512
- "ENV1"
1792
+ { env: "ENV1" }
1513
1793
  );
1514
1794
 
1515
- expect(config).toEqual(expect.objectContaining(environment));
1795
+ expect(config).toEqual(
1796
+ expect.objectContaining({ ...rawEnv, main: resolvedMain })
1797
+ );
1516
1798
  expect(diagnostics.hasErrors()).toBe(false);
1517
1799
  expect(diagnostics.hasWarnings()).toBe(false);
1518
1800
  });
@@ -1520,7 +1802,7 @@ describe("normalizeAndValidateConfig()", () => {
1520
1802
  describe("non-legacy", () => {
1521
1803
  it("should use top-level `name` field", () => {
1522
1804
  const rawConfig: RawConfig = {
1523
- name: "NAME",
1805
+ name: "mock-name",
1524
1806
  legacy_env: false,
1525
1807
  env: { DEV: {} },
1526
1808
  };
@@ -1528,12 +1810,16 @@ describe("normalizeAndValidateConfig()", () => {
1528
1810
  const { config, diagnostics } = normalizeAndValidateConfig(
1529
1811
  rawConfig,
1530
1812
  undefined,
1531
- "DEV"
1813
+ { env: "DEV" }
1532
1814
  );
1533
1815
 
1534
- expect(config.name).toEqual("NAME");
1816
+ expect(config.name).toEqual("mock-name");
1535
1817
  expect(diagnostics.hasErrors()).toBe(false);
1536
- expect(diagnostics.hasWarnings()).toBe(false);
1818
+ expect(diagnostics.hasWarnings()).toBe(true);
1819
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1820
+ "Processing wrangler configuration:
1821
+ - Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
1822
+ `);
1537
1823
  });
1538
1824
 
1539
1825
  it("should error if named environment contains a `name` field, even if there is no top-level name", () => {
@@ -1541,7 +1827,7 @@ describe("normalizeAndValidateConfig()", () => {
1541
1827
  legacy_env: false,
1542
1828
  env: {
1543
1829
  DEV: {
1544
- name: "ENV_NAME",
1830
+ name: "mock-env-name",
1545
1831
  },
1546
1832
  },
1547
1833
  };
@@ -1549,10 +1835,16 @@ describe("normalizeAndValidateConfig()", () => {
1549
1835
  const { config, diagnostics } = normalizeAndValidateConfig(
1550
1836
  rawConfig,
1551
1837
  undefined,
1552
- "DEV"
1838
+ { env: "DEV" }
1553
1839
  );
1554
1840
 
1555
1841
  expect(config.name).toBeUndefined();
1842
+ expect(diagnostics.hasWarnings()).toBe(true);
1843
+ expect(diagnostics.hasErrors()).toBe(true);
1844
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1845
+ "Processing wrangler configuration:
1846
+ - Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
1847
+ `);
1556
1848
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1557
1849
  "Processing wrangler configuration:
1558
1850
 
@@ -1560,16 +1852,15 @@ describe("normalizeAndValidateConfig()", () => {
1560
1852
  - The \\"name\\" field is not allowed in named service environments.
1561
1853
  Please remove the field from this environment."
1562
1854
  `);
1563
- expect(diagnostics.hasWarnings()).toBe(false);
1564
1855
  });
1565
1856
 
1566
1857
  it("should error if top-level config and a named environment both contain a `name` field", () => {
1567
1858
  const rawConfig: RawConfig = {
1568
- name: "NAME",
1859
+ name: "mock-name",
1569
1860
  legacy_env: false,
1570
1861
  env: {
1571
1862
  DEV: {
1572
- name: "ENV_NAME",
1863
+ name: "mock-env-name",
1573
1864
  },
1574
1865
  },
1575
1866
  };
@@ -1577,10 +1868,16 @@ describe("normalizeAndValidateConfig()", () => {
1577
1868
  const { config, diagnostics } = normalizeAndValidateConfig(
1578
1869
  rawConfig,
1579
1870
  undefined,
1580
- "DEV"
1871
+ { env: "DEV" }
1581
1872
  );
1582
1873
 
1583
- expect(config.name).toEqual("NAME");
1874
+ expect(config.name).toEqual("mock-name");
1875
+ expect(diagnostics.hasWarnings()).toBe(true);
1876
+ expect(diagnostics.hasErrors()).toBe(true);
1877
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1878
+ "Processing wrangler configuration:
1879
+ - Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
1880
+ `);
1584
1881
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1585
1882
  "Processing wrangler configuration:
1586
1883
 
@@ -1588,10 +1885,73 @@ describe("normalizeAndValidateConfig()", () => {
1588
1885
  - The \\"name\\" field is not allowed in named service environments.
1589
1886
  Please remove the field from this environment."
1590
1887
  `);
1591
- expect(diagnostics.hasWarnings()).toBe(false);
1592
1888
  });
1593
1889
  });
1594
1890
 
1891
+ it("should error if named environment contains a `account_id` field, even if there is no top-level name", () => {
1892
+ const rawConfig: RawConfig = {
1893
+ legacy_env: false,
1894
+ env: {
1895
+ DEV: {
1896
+ account_id: "some_account_id",
1897
+ },
1898
+ },
1899
+ };
1900
+
1901
+ const { config, diagnostics } = normalizeAndValidateConfig(
1902
+ rawConfig,
1903
+ undefined,
1904
+ { env: "DEV" }
1905
+ );
1906
+
1907
+ expect(diagnostics.hasWarnings()).toBe(true);
1908
+ expect(config.account_id).toBeUndefined();
1909
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1910
+ "Processing wrangler configuration:
1911
+ - Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
1912
+ `);
1913
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1914
+ "Processing wrangler configuration:
1915
+
1916
+ - \\"env.DEV\\" environment configuration
1917
+ - The \\"account_id\\" field is not allowed in named service environments.
1918
+ Please remove the field from this environment."
1919
+ `);
1920
+ });
1921
+
1922
+ it("should error if top-level config and a named environment both contain a `account_id` field", () => {
1923
+ const rawConfig: RawConfig = {
1924
+ account_id: "ACCOUNT_ID",
1925
+ legacy_env: false,
1926
+ env: {
1927
+ DEV: {
1928
+ account_id: "ENV_ACCOUNT_ID",
1929
+ },
1930
+ },
1931
+ };
1932
+
1933
+ const { config, diagnostics } = normalizeAndValidateConfig(
1934
+ rawConfig,
1935
+ undefined,
1936
+ { env: "DEV" }
1937
+ );
1938
+
1939
+ expect(config.account_id).toEqual("ACCOUNT_ID");
1940
+ expect(diagnostics.hasErrors()).toBe(true);
1941
+ expect(diagnostics.hasWarnings()).toBe(true);
1942
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1943
+ "Processing wrangler configuration:
1944
+ - Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
1945
+ `);
1946
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1947
+ "Processing wrangler configuration:
1948
+
1949
+ - \\"env.DEV\\" environment configuration
1950
+ - The \\"account_id\\" field is not allowed in named service environments.
1951
+ Please remove the field from this environment."
1952
+ `);
1953
+ });
1954
+
1595
1955
  it("should warn for non-inherited fields that are missing in environments", () => {
1596
1956
  const vars: RawConfig["vars"] = {
1597
1957
  FOO: "foo",
@@ -1616,7 +1976,7 @@ describe("normalizeAndValidateConfig()", () => {
1616
1976
  const { config, diagnostics } = normalizeAndValidateConfig(
1617
1977
  rawConfig,
1618
1978
  undefined,
1619
- "ENV1"
1979
+ { env: "ENV1" }
1620
1980
  );
1621
1981
 
1622
1982
  expect(config).toEqual(
@@ -1662,14 +2022,21 @@ describe("normalizeAndValidateConfig()", () => {
1662
2022
  route: 888,
1663
2023
  jsx_factory: 999,
1664
2024
  jsx_fragment: 1000,
2025
+ tsconfig: 123,
1665
2026
  triggers: { crons: [1111, 1222] },
1666
2027
  usage_model: "INVALID",
2028
+ main: 1333,
2029
+ build: {
2030
+ command: 1444,
2031
+ cwd: 1555,
2032
+ watch_dir: 1666,
2033
+ },
1667
2034
  } as unknown as RawEnvironment;
1668
2035
 
1669
2036
  const { config, diagnostics } = normalizeAndValidateConfig(
1670
2037
  { env: { ENV1: expectedConfig } },
1671
2038
  undefined,
1672
- "ENV1"
2039
+ { env: "ENV1" }
1673
2040
  );
1674
2041
 
1675
2042
  expect(config).toEqual(expect.objectContaining(expectedConfig));
@@ -1678,16 +2045,24 @@ describe("normalizeAndValidateConfig()", () => {
1678
2045
  "Processing wrangler configuration:
1679
2046
 
1680
2047
  - \\"env.ENV1\\" environment configuration
1681
- - Expected \\"route\\" to be of type string but got 888.
1682
- - Expected \\"routes\\" to be of type string array but got [666,777].
2048
+ - Expected \\"route\\" to be either a string, or an object with shape { pattern, zone_id | zone_name }, but got 888.
2049
+ - Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, zone_id | zone_name }, but these weren't valid: [
2050
+ 666,
2051
+ 777
2052
+ ].
1683
2053
  - Expected exactly one of the following fields [\\"routes\\",\\"route\\"].
1684
2054
  - Expected \\"workers_dev\\" to be of type boolean but got \\"BAD\\".
2055
+ - Expected \\"build.command\\" to be of type string but got 1444.
2056
+ - Expected \\"build.cwd\\" to be of type string but got 1555.
2057
+ - Expected \\"build.watch_dir\\" to be of type string but got 1666.
1685
2058
  - Expected \\"account_id\\" to be of type string but got 222.
1686
2059
  - Expected \\"compatibility_date\\" to be of type string but got 333.
1687
2060
  - Expected \\"compatibility_flags\\" to be of type string array but got [444,555].
1688
2061
  - Expected \\"jsx_factory\\" to be of type string but got 999.
1689
2062
  - Expected \\"jsx_fragment\\" to be of type string but got 1000.
1690
- - Expected \\"name\\" to be of type string but got 111.
2063
+ - Expected \\"tsconfig\\" to be of type string but got 123.
2064
+ - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
2065
+ - Expected \\"main\\" to be of type string but got 1333.
1691
2066
  - Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
1692
2067
  `);
1693
2068
  });
@@ -1697,7 +2072,7 @@ describe("normalizeAndValidateConfig()", () => {
1697
2072
  const { config, diagnostics } = normalizeAndValidateConfig(
1698
2073
  { env: { ENV1: { durable_objects: [] } } } as unknown as RawConfig,
1699
2074
  undefined,
1700
- "ENV1"
2075
+ { env: "ENV1" }
1701
2076
  );
1702
2077
 
1703
2078
  expect(config).toEqual(
@@ -1716,7 +2091,7 @@ describe("normalizeAndValidateConfig()", () => {
1716
2091
  const { config, diagnostics } = normalizeAndValidateConfig(
1717
2092
  { env: { ENV1: { durable_objects: "BAD" } } } as unknown as RawConfig,
1718
2093
  undefined,
1719
- "ENV1"
2094
+ { env: "ENV1" }
1720
2095
  );
1721
2096
 
1722
2097
  expect(config).toEqual(
@@ -1735,7 +2110,7 @@ describe("normalizeAndValidateConfig()", () => {
1735
2110
  const { config, diagnostics } = normalizeAndValidateConfig(
1736
2111
  { env: { ENV1: { durable_objects: 999 } } } as unknown as RawConfig,
1737
2112
  undefined,
1738
- "ENV1"
2113
+ { env: "ENV1" }
1739
2114
  );
1740
2115
 
1741
2116
  expect(config).toEqual(
@@ -1754,7 +2129,7 @@ describe("normalizeAndValidateConfig()", () => {
1754
2129
  const { config, diagnostics } = normalizeAndValidateConfig(
1755
2130
  { env: { ENV1: { durable_objects: null } } } as unknown as RawConfig,
1756
2131
  undefined,
1757
- "ENV1"
2132
+ { env: "ENV1" }
1758
2133
  );
1759
2134
 
1760
2135
  expect(config).toEqual(
@@ -1773,7 +2148,7 @@ describe("normalizeAndValidateConfig()", () => {
1773
2148
  const { config, diagnostics } = normalizeAndValidateConfig(
1774
2149
  { env: { ENV1: { durable_objects: {} } } } as unknown as RawConfig,
1775
2150
  undefined,
1776
- "ENV1"
2151
+ { env: "ENV1" }
1777
2152
  );
1778
2153
 
1779
2154
  expect(config).toEqual(
@@ -1794,7 +2169,7 @@ describe("normalizeAndValidateConfig()", () => {
1794
2169
  env: { ENV1: { durable_objects: { bindings: {} } } },
1795
2170
  } as unknown as RawConfig,
1796
2171
  undefined,
1797
- "ENV1"
2172
+ { env: "ENV1" }
1798
2173
  );
1799
2174
 
1800
2175
  expect(config).toEqual(
@@ -1817,7 +2192,7 @@ describe("normalizeAndValidateConfig()", () => {
1817
2192
  env: { ENV1: { durable_objects: { bindings: "BAD" } } },
1818
2193
  } as unknown as RawConfig,
1819
2194
  undefined,
1820
- "ENV1"
2195
+ { env: "ENV1" }
1821
2196
  );
1822
2197
 
1823
2198
  expect(config).toEqual(
@@ -1840,7 +2215,7 @@ describe("normalizeAndValidateConfig()", () => {
1840
2215
  env: { ENV1: { durable_objects: { bindings: 999 } } },
1841
2216
  } as unknown as RawConfig,
1842
2217
  undefined,
1843
- "ENV1"
2218
+ { env: "ENV1" }
1844
2219
  );
1845
2220
 
1846
2221
  expect(config).toEqual(
@@ -1863,7 +2238,7 @@ describe("normalizeAndValidateConfig()", () => {
1863
2238
  env: { ENV1: { durable_objects: { bindings: null } } },
1864
2239
  } as unknown as RawConfig,
1865
2240
  undefined,
1866
- "ENV1"
2241
+ { env: "ENV1" }
1867
2242
  );
1868
2243
 
1869
2244
  expect(config).toEqual(
@@ -1901,7 +2276,7 @@ describe("normalizeAndValidateConfig()", () => {
1901
2276
  },
1902
2277
  } as unknown as RawConfig,
1903
2278
  undefined,
1904
- "ENV1"
2279
+ { env: "ENV1" }
1905
2280
  );
1906
2281
 
1907
2282
  expect(config).toEqual(
@@ -1939,7 +2314,7 @@ describe("normalizeAndValidateConfig()", () => {
1939
2314
  const { config, diagnostics } = normalizeAndValidateConfig(
1940
2315
  { env: { ENV1: { kv_namespaces: {} } } } as unknown as RawConfig,
1941
2316
  undefined,
1942
- "ENV1"
2317
+ { env: "ENV1" }
1943
2318
  );
1944
2319
 
1945
2320
  expect(config).toEqual(
@@ -1958,7 +2333,7 @@ describe("normalizeAndValidateConfig()", () => {
1958
2333
  const { config, diagnostics } = normalizeAndValidateConfig(
1959
2334
  { env: { ENV1: { kv_namespaces: "BAD" } } } as unknown as RawConfig,
1960
2335
  undefined,
1961
- "ENV1"
2336
+ { env: "ENV1" }
1962
2337
  );
1963
2338
 
1964
2339
  expect(config).toEqual(
@@ -1977,7 +2352,7 @@ describe("normalizeAndValidateConfig()", () => {
1977
2352
  const { config, diagnostics } = normalizeAndValidateConfig(
1978
2353
  { env: { ENV1: { kv_namespaces: 999 } } } as unknown as RawConfig,
1979
2354
  undefined,
1980
- "ENV1"
2355
+ { env: "ENV1" }
1981
2356
  );
1982
2357
 
1983
2358
  expect(config).toEqual(
@@ -1996,7 +2371,7 @@ describe("normalizeAndValidateConfig()", () => {
1996
2371
  const { config, diagnostics } = normalizeAndValidateConfig(
1997
2372
  { env: { ENV1: { kv_namespaces: null } } } as unknown as RawConfig,
1998
2373
  undefined,
1999
- "ENV1"
2374
+ { env: "ENV1" }
2000
2375
  );
2001
2376
 
2002
2377
  expect(config).toEqual(
@@ -2030,7 +2405,7 @@ describe("normalizeAndValidateConfig()", () => {
2030
2405
  },
2031
2406
  } as unknown as RawConfig,
2032
2407
  undefined,
2033
- "ENV1"
2408
+ { env: "ENV1" }
2034
2409
  );
2035
2410
 
2036
2411
  expect(config).toEqual(
@@ -2058,7 +2433,7 @@ describe("normalizeAndValidateConfig()", () => {
2058
2433
  const { config, diagnostics } = normalizeAndValidateConfig(
2059
2434
  { env: { ENV1: { r2_buckets: {} } } } as unknown as RawConfig,
2060
2435
  undefined,
2061
- "ENV1"
2436
+ { env: "ENV1" }
2062
2437
  );
2063
2438
 
2064
2439
  expect(config).toEqual(
@@ -2077,7 +2452,7 @@ describe("normalizeAndValidateConfig()", () => {
2077
2452
  const { config, diagnostics } = normalizeAndValidateConfig(
2078
2453
  { env: { ENV1: { r2_buckets: "BAD" } } } as unknown as RawConfig,
2079
2454
  undefined,
2080
- "ENV1"
2455
+ { env: "ENV1" }
2081
2456
  );
2082
2457
 
2083
2458
  expect(config).toEqual(
@@ -2096,7 +2471,7 @@ describe("normalizeAndValidateConfig()", () => {
2096
2471
  const { config, diagnostics } = normalizeAndValidateConfig(
2097
2472
  { env: { ENV1: { r2_buckets: 999 } } } as unknown as RawConfig,
2098
2473
  undefined,
2099
- "ENV1"
2474
+ { env: "ENV1" }
2100
2475
  );
2101
2476
 
2102
2477
  expect(config).toEqual(
@@ -2115,7 +2490,7 @@ describe("normalizeAndValidateConfig()", () => {
2115
2490
  const { config, diagnostics } = normalizeAndValidateConfig(
2116
2491
  { env: { ENV1: { r2_buckets: null } } } as unknown as RawConfig,
2117
2492
  undefined,
2118
- "ENV1"
2493
+ { env: "ENV1" }
2119
2494
  );
2120
2495
 
2121
2496
  expect(config).toEqual(
@@ -2149,7 +2524,7 @@ describe("normalizeAndValidateConfig()", () => {
2149
2524
  },
2150
2525
  } as unknown as RawConfig,
2151
2526
  undefined,
2152
- "ENV1"
2527
+ { env: "ENV1" }
2153
2528
  );
2154
2529
 
2155
2530
  expect(config).toEqual(
@@ -2177,7 +2552,7 @@ describe("normalizeAndValidateConfig()", () => {
2177
2552
  const { config, diagnostics } = normalizeAndValidateConfig(
2178
2553
  { env: { ENV1: { unsafe: [] } } } as unknown as RawConfig,
2179
2554
  undefined,
2180
- "ENV1"
2555
+ { env: "ENV1" }
2181
2556
  );
2182
2557
 
2183
2558
  expect(config).toEqual(
@@ -2201,7 +2576,7 @@ describe("normalizeAndValidateConfig()", () => {
2201
2576
  const { config, diagnostics } = normalizeAndValidateConfig(
2202
2577
  { env: { ENV1: { unsafe: "BAD" } } } as unknown as RawConfig,
2203
2578
  undefined,
2204
- "ENV1"
2579
+ { env: "ENV1" }
2205
2580
  );
2206
2581
 
2207
2582
  expect(config).toEqual(
@@ -2225,7 +2600,7 @@ describe("normalizeAndValidateConfig()", () => {
2225
2600
  const { config, diagnostics } = normalizeAndValidateConfig(
2226
2601
  { env: { ENV1: { unsafe: 999 } } } as unknown as RawConfig,
2227
2602
  undefined,
2228
- "ENV1"
2603
+ { env: "ENV1" }
2229
2604
  );
2230
2605
 
2231
2606
  expect(config).toEqual(
@@ -2249,7 +2624,7 @@ describe("normalizeAndValidateConfig()", () => {
2249
2624
  const { config, diagnostics } = normalizeAndValidateConfig(
2250
2625
  { env: { ENV1: { unsafe: null } } } as unknown as RawConfig,
2251
2626
  undefined,
2252
- "ENV1"
2627
+ { env: "ENV1" }
2253
2628
  );
2254
2629
 
2255
2630
  expect(config).toEqual(
@@ -2273,7 +2648,7 @@ describe("normalizeAndValidateConfig()", () => {
2273
2648
  const { config, diagnostics } = normalizeAndValidateConfig(
2274
2649
  { env: { ENV1: { unsafe: {} } } } as unknown as RawConfig,
2275
2650
  undefined,
2276
- "ENV1"
2651
+ { env: "ENV1" }
2277
2652
  );
2278
2653
 
2279
2654
  expect(config).toEqual(
@@ -2299,7 +2674,7 @@ describe("normalizeAndValidateConfig()", () => {
2299
2674
  env: { ENV1: { unsafe: { bindings: {} } } },
2300
2675
  } as unknown as RawConfig,
2301
2676
  undefined,
2302
- "ENV1"
2677
+ { env: "ENV1" }
2303
2678
  );
2304
2679
 
2305
2680
  expect(config).toEqual(
@@ -2327,7 +2702,7 @@ describe("normalizeAndValidateConfig()", () => {
2327
2702
  env: { ENV1: { unsafe: { bindings: "BAD" } } },
2328
2703
  } as unknown as RawConfig,
2329
2704
  undefined,
2330
- "ENV1"
2705
+ { env: "ENV1" }
2331
2706
  );
2332
2707
 
2333
2708
  expect(config).toEqual(
@@ -2355,7 +2730,7 @@ describe("normalizeAndValidateConfig()", () => {
2355
2730
  env: { ENV1: { unsafe: { bindings: 999 } } },
2356
2731
  } as unknown as RawConfig,
2357
2732
  undefined,
2358
- "ENV1"
2733
+ { env: "ENV1" }
2359
2734
  );
2360
2735
 
2361
2736
  expect(config).toEqual(
@@ -2383,7 +2758,7 @@ describe("normalizeAndValidateConfig()", () => {
2383
2758
  env: { ENV1: { unsafe: { bindings: null } } },
2384
2759
  } as unknown as RawConfig,
2385
2760
  undefined,
2386
- "ENV1"
2761
+ { env: "ENV1" }
2387
2762
  );
2388
2763
 
2389
2764
  expect(config).toEqual(
@@ -2426,7 +2801,7 @@ describe("normalizeAndValidateConfig()", () => {
2426
2801
  },
2427
2802
  } as unknown as RawConfig,
2428
2803
  undefined,
2429
- "ENV1"
2804
+ { env: "ENV1" }
2430
2805
  );
2431
2806
 
2432
2807
  expect(config).toEqual(
@@ -2465,7 +2840,7 @@ describe("normalizeAndValidateConfig()", () => {
2465
2840
  zone_id: "ZONE_ID",
2466
2841
  experimental_services: [
2467
2842
  {
2468
- name: "NAME",
2843
+ name: "mock-name",
2469
2844
  service: "SERVICE",
2470
2845
  environment: "ENV",
2471
2846
  },
@@ -2479,7 +2854,7 @@ describe("normalizeAndValidateConfig()", () => {
2479
2854
  },
2480
2855
  },
2481
2856
  undefined,
2482
- "ENV1"
2857
+ { env: "ENV1" }
2483
2858
  );
2484
2859
 
2485
2860
  expect("experimental_services" in config).toBe(false);
@@ -2491,13 +2866,13 @@ describe("normalizeAndValidateConfig()", () => {
2491
2866
  "Processing wrangler configuration:
2492
2867
 
2493
2868
  - \\"env.ENV1\\" environment configuration
2494
- - DEPRECATION: \\"zone_id\\":
2869
+ - Deprecation: \\"zone_id\\":
2495
2870
  This is unnecessary since we can deduce this from routes directly.
2496
- - DEPRECATION: \\"experimental_services\\":
2871
+ - Deprecation: \\"experimental_services\\":
2497
2872
  The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
2498
2873
  \`\`\`
2499
2874
  [[unsafe.bindings]]
2500
- name = \\"NAME\\"
2875
+ name = \\"mock-name\\"
2501
2876
  type = \\"service\\"
2502
2877
  service = \\"SERVICE\\"
2503
2878
  environment = \\"ENV\\"
@@ -2509,7 +2884,7 @@ describe("normalizeAndValidateConfig()", () => {
2509
2884
  describe("route & routes fields", () => {
2510
2885
  it("should error if both route and routes are specified in the same environment", () => {
2511
2886
  const environment: RawEnvironment = {
2512
- name: "ENV_NAME",
2887
+ name: "mock-env-name",
2513
2888
  account_id: "ENV_ACCOUNT_ID",
2514
2889
  compatibility_date: "2022-02-02",
2515
2890
  compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
@@ -2522,7 +2897,7 @@ describe("normalizeAndValidateConfig()", () => {
2522
2897
  usage_model: "unbound",
2523
2898
  };
2524
2899
  const expectedConfig: RawConfig = {
2525
- name: "NAME",
2900
+ name: "mock-name",
2526
2901
  account_id: "ACCOUNT_ID",
2527
2902
  compatibility_date: "2022-01-01",
2528
2903
  compatibility_flags: ["FLAG1", "FLAG2"],
@@ -2540,7 +2915,7 @@ describe("normalizeAndValidateConfig()", () => {
2540
2915
  const { config, diagnostics } = normalizeAndValidateConfig(
2541
2916
  expectedConfig,
2542
2917
  undefined,
2543
- "ENV1"
2918
+ { env: "ENV1" }
2544
2919
  );
2545
2920
 
2546
2921
  expect(config).toEqual(expect.objectContaining(environment));
@@ -2557,7 +2932,7 @@ describe("normalizeAndValidateConfig()", () => {
2557
2932
 
2558
2933
  it("should error if both route and routes are specified in the top-level environment", () => {
2559
2934
  const environment: RawEnvironment = {
2560
- name: "ENV_NAME",
2935
+ name: "mock-env-name",
2561
2936
  account_id: "ENV_ACCOUNT_ID",
2562
2937
  compatibility_date: "2022-02-02",
2563
2938
  compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
@@ -2569,7 +2944,7 @@ describe("normalizeAndValidateConfig()", () => {
2569
2944
  usage_model: "unbound",
2570
2945
  };
2571
2946
  const expectedConfig: RawConfig = {
2572
- name: "NAME",
2947
+ name: "mock-name",
2573
2948
  account_id: "ACCOUNT_ID",
2574
2949
  compatibility_date: "2022-01-01",
2575
2950
  compatibility_flags: ["FLAG1", "FLAG2"],
@@ -2588,7 +2963,7 @@ describe("normalizeAndValidateConfig()", () => {
2588
2963
  const { config, diagnostics } = normalizeAndValidateConfig(
2589
2964
  expectedConfig,
2590
2965
  undefined,
2591
- "ENV1"
2966
+ { env: "ENV1" }
2592
2967
  );
2593
2968
 
2594
2969
  expect(config).toEqual(expect.objectContaining(environment));
@@ -2603,7 +2978,7 @@ describe("normalizeAndValidateConfig()", () => {
2603
2978
 
2604
2979
  it("should not error if <env>.route and <top-level>.routes are specified", () => {
2605
2980
  const environment: RawEnvironment = {
2606
- name: "ENV_NAME",
2981
+ name: "mock-env-name",
2607
2982
  account_id: "ENV_ACCOUNT_ID",
2608
2983
  compatibility_date: "2022-02-02",
2609
2984
  compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
@@ -2615,7 +2990,7 @@ describe("normalizeAndValidateConfig()", () => {
2615
2990
  usage_model: "unbound",
2616
2991
  };
2617
2992
  const expectedConfig: RawConfig = {
2618
- name: "NAME",
2993
+ name: "mock-name",
2619
2994
  account_id: "ACCOUNT_ID",
2620
2995
  compatibility_date: "2022-01-01",
2621
2996
  compatibility_flags: ["FLAG1", "FLAG2"],
@@ -2633,7 +3008,7 @@ describe("normalizeAndValidateConfig()", () => {
2633
3008
  const { config, diagnostics } = normalizeAndValidateConfig(
2634
3009
  expectedConfig,
2635
3010
  undefined,
2636
- "ENV1"
3011
+ { env: "ENV1" }
2637
3012
  );
2638
3013
 
2639
3014
  expect(config).toEqual(expect.objectContaining(environment));
@@ -2643,7 +3018,7 @@ describe("normalizeAndValidateConfig()", () => {
2643
3018
 
2644
3019
  it("should not error if <env>.routes and <top-level>.route are specified", () => {
2645
3020
  const environment: RawEnvironment = {
2646
- name: "ENV_NAME",
3021
+ name: "mock-env-name",
2647
3022
  account_id: "ENV_ACCOUNT_ID",
2648
3023
  compatibility_date: "2022-02-02",
2649
3024
  compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
@@ -2655,7 +3030,7 @@ describe("normalizeAndValidateConfig()", () => {
2655
3030
  usage_model: "unbound",
2656
3031
  };
2657
3032
  const expectedConfig: RawConfig = {
2658
- name: "NAME",
3033
+ name: "mock-name",
2659
3034
  account_id: "ACCOUNT_ID",
2660
3035
  compatibility_date: "2022-01-01",
2661
3036
  compatibility_flags: ["FLAG1", "FLAG2"],
@@ -2673,7 +3048,7 @@ describe("normalizeAndValidateConfig()", () => {
2673
3048
  const { config, diagnostics } = normalizeAndValidateConfig(
2674
3049
  expectedConfig,
2675
3050
  undefined,
2676
- "ENV1"
3051
+ { env: "ENV1" }
2677
3052
  );
2678
3053
 
2679
3054
  expect(config).toEqual(expect.objectContaining(environment));
@@ -2683,7 +3058,7 @@ describe("normalizeAndValidateConfig()", () => {
2683
3058
 
2684
3059
  it("should not error if <env1>.route and <env2>.routes are specified", () => {
2685
3060
  const environment1: RawEnvironment = {
2686
- name: "ENV_NAME",
3061
+ name: "mock-env-name",
2687
3062
  account_id: "ENV_ACCOUNT_ID",
2688
3063
  compatibility_date: "2022-02-02",
2689
3064
  compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
@@ -2695,7 +3070,7 @@ describe("normalizeAndValidateConfig()", () => {
2695
3070
  usage_model: "unbound",
2696
3071
  };
2697
3072
  const environment2: RawEnvironment = {
2698
- name: "ENV_NAME",
3073
+ name: "mock-env-name",
2699
3074
  account_id: "ENV_ACCOUNT_ID",
2700
3075
  compatibility_date: "2022-02-02",
2701
3076
  compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
@@ -2707,7 +3082,7 @@ describe("normalizeAndValidateConfig()", () => {
2707
3082
  usage_model: "unbound",
2708
3083
  };
2709
3084
  const expectedConfig: RawConfig = {
2710
- name: "NAME",
3085
+ name: "mock-name",
2711
3086
  account_id: "ACCOUNT_ID",
2712
3087
  compatibility_date: "2022-01-01",
2713
3088
  compatibility_flags: ["FLAG1", "FLAG2"],
@@ -2723,21 +3098,17 @@ describe("normalizeAndValidateConfig()", () => {
2723
3098
  },
2724
3099
  };
2725
3100
 
2726
- const result1 = normalizeAndValidateConfig(
2727
- expectedConfig,
2728
- undefined,
2729
- "ENV1"
2730
- );
3101
+ const result1 = normalizeAndValidateConfig(expectedConfig, undefined, {
3102
+ env: "ENV1",
3103
+ });
2731
3104
 
2732
3105
  expect(result1.config).toEqual(expect.objectContaining(environment1));
2733
3106
  expect(result1.diagnostics.hasErrors()).toBe(false);
2734
3107
  expect(result1.diagnostics.hasWarnings()).toBe(false);
2735
3108
 
2736
- const result2 = normalizeAndValidateConfig(
2737
- expectedConfig,
2738
- undefined,
2739
- "ENV2"
2740
- );
3109
+ const result2 = normalizeAndValidateConfig(expectedConfig, undefined, {
3110
+ env: "ENV2",
3111
+ });
2741
3112
 
2742
3113
  expect(result2.config).toEqual(expect.objectContaining(environment2));
2743
3114
  expect(result2.diagnostics.hasErrors()).toBe(false);