wrangler 0.0.0-ece06ea → 0.0.0-eebdb6c

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 (39) hide show
  1. package/package.json +22 -15
  2. package/pages/functions/buildWorker.ts +57 -0
  3. package/pages/functions/filepath-routing.test.ts +32 -0
  4. package/pages/functions/filepath-routing.ts +225 -0
  5. package/pages/functions/identifiers.ts +78 -0
  6. package/pages/functions/routes.ts +158 -0
  7. package/pages/functions/template-worker.ts +135 -0
  8. package/src/__tests__/index.test.ts +254 -120
  9. package/src/__tests__/jest.setup.ts +22 -0
  10. package/src/__tests__/kv.test.ts +1098 -0
  11. package/src/__tests__/mock-cfetch.ts +171 -0
  12. package/src/__tests__/mock-dialogs.ts +65 -0
  13. package/src/__tests__/run-in-tmp.ts +19 -0
  14. package/src/__tests__/run-wrangler.ts +32 -0
  15. package/src/api/form_data.ts +70 -97
  16. package/src/api/inspect.ts +0 -11
  17. package/src/api/preview.ts +29 -24
  18. package/src/api/worker.ts +34 -40
  19. package/src/cfetch/index.ts +103 -0
  20. package/src/cfetch/internal.ts +69 -0
  21. package/src/cli.ts +6 -7
  22. package/src/config.ts +14 -7
  23. package/src/dev.tsx +274 -131
  24. package/src/dialogs.tsx +4 -12
  25. package/src/index.tsx +304 -245
  26. package/src/kv.tsx +101 -45
  27. package/src/module-collection.ts +64 -0
  28. package/src/pages.tsx +681 -104
  29. package/src/proxy.ts +103 -0
  30. package/src/publish.ts +54 -58
  31. package/src/sites.tsx +5 -6
  32. package/src/tail.tsx +5 -3
  33. package/src/user.tsx +9 -16
  34. package/wrangler-dist/cli.js +36633 -49770
  35. package/wrangler-dist/cli.js.map +3 -3
  36. package/src/__tests__/fixtures/init/.gitkeep +0 -0
  37. package/src/__tests__/mock-cfetch.js +0 -46
  38. package/src/cfetch.ts +0 -72
  39. package/src/util/fetch.ts +0 -74
@@ -0,0 +1,135 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import { match } from "path-to-regexp";
4
+ import type { HTTPMethod } from "./routes";
5
+
6
+ /* TODO: Grab these from @cloudflare/workers-types instead */
7
+ type Params<P extends string = any> = Record<P, string | string[]>;
8
+
9
+ type EventContext<Env, P extends string, Data> = {
10
+ request: Request;
11
+ waitUntil: (promise: Promise<any>) => void;
12
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
13
+ env: Env & { ASSETS: { fetch: typeof fetch } };
14
+ params: Params<P>;
15
+ data: Data;
16
+ };
17
+
18
+ declare type PagesFunction<
19
+ Env = unknown,
20
+ P extends string = any,
21
+ Data extends Record<string, unknown> = Record<string, unknown>
22
+ > = (context: EventContext<Env, P, Data>) => Response | Promise<Response>;
23
+ /* end @cloudflare/workers-types */
24
+
25
+ type RouteHandler = {
26
+ routePath: string;
27
+ methods: HTTPMethod[];
28
+ modules: PagesFunction[];
29
+ middlewares: PagesFunction[];
30
+ };
31
+
32
+ // inject `routes` via ESBuild
33
+ declare const routes: RouteHandler[];
34
+
35
+ // expect an ASSETS fetcher binding pointing to the asset-server stage
36
+ type Env = {
37
+ [name: string]: any;
38
+ ASSETS: { fetch(url: string, init: RequestInit): Promise<Response> };
39
+ };
40
+
41
+ type WorkerContext = {
42
+ waitUntil: (promise: Promise<any>) => void;
43
+ };
44
+
45
+ function* executeRequest(request: Request, env: Env) {
46
+ const requestPath = new URL(request.url).pathname;
47
+
48
+ // First, iterate through the routes and execute "middlewares" on partial route matches
49
+ for (const route of routes) {
50
+ if (
51
+ route.methods.length &&
52
+ !route.methods.includes(request.method as HTTPMethod)
53
+ ) {
54
+ continue;
55
+ }
56
+
57
+ const routeMatcher = match(route.routePath, { end: false });
58
+ const matchResult = routeMatcher(requestPath);
59
+ if (matchResult) {
60
+ for (const handler of route.middlewares.flat()) {
61
+ yield {
62
+ handler,
63
+ params: matchResult.params as Params,
64
+ };
65
+ }
66
+ }
67
+ }
68
+
69
+ // Then look for the first exact route match and execute its "modules"
70
+ for (const route of routes) {
71
+ if (
72
+ route.methods.length &&
73
+ !route.methods.includes(request.method as HTTPMethod)
74
+ ) {
75
+ continue;
76
+ }
77
+
78
+ const routeMatcher = match(route.routePath, { end: true });
79
+ const matchResult = routeMatcher(requestPath);
80
+ if (matchResult && route.modules.length) {
81
+ for (const handler of route.modules.flat()) {
82
+ yield {
83
+ handler,
84
+ params: matchResult.params as Params,
85
+ };
86
+ }
87
+ break;
88
+ }
89
+ }
90
+
91
+ // Finally, yield to the asset-server
92
+ return {
93
+ handler: () => env.ASSETS.fetch(request.url, request),
94
+ params: {} as Params,
95
+ };
96
+ }
97
+
98
+ export default {
99
+ async fetch(request: Request, env: Env, workerContext: WorkerContext) {
100
+ const handlerIterator = executeRequest(request, env);
101
+ const data = {}; // arbitrary data the user can set between functions
102
+ const next = async (input?: RequestInfo, init?: RequestInit) => {
103
+ if (input !== undefined) {
104
+ request = new Request(input, init);
105
+ }
106
+
107
+ const { value } = handlerIterator.next();
108
+ if (value) {
109
+ const { handler, params } = value;
110
+ const context: EventContext<unknown, any, any> = {
111
+ request: new Request(request.clone()),
112
+ next,
113
+ params,
114
+ data,
115
+ env,
116
+ waitUntil: workerContext.waitUntil.bind(workerContext),
117
+ };
118
+
119
+ const response = await handler(context);
120
+
121
+ // https://fetch.spec.whatwg.org/#null-body-status
122
+ return new Response(
123
+ [101, 204, 205, 304].includes(response.status) ? null : response.body,
124
+ response
125
+ );
126
+ }
127
+ };
128
+
129
+ try {
130
+ return next();
131
+ } catch (err) {
132
+ return new Response("Internal Error", { status: 500 });
133
+ }
134
+ },
135
+ };
@@ -1,153 +1,287 @@
1
- import * as fs from "node:fs";
2
1
  import * as fsp from "node:fs/promises";
3
- import * as path from "node:path";
4
2
  import * as TOML from "@iarna/toml";
5
- import { main } from "../index";
6
- // @ts-expect-error we're mocking cfetch, so of course setMock isn't a thing
7
- import { setMock, unsetAllMocks } from "../cfetch";
3
+ import { mockConfirm } from "./mock-dialogs";
4
+ import { runWrangler } from "./run-wrangler";
5
+ import { runInTempDir } from "./run-in-tmp";
6
+ import * as fs from "node:fs";
8
7
 
9
- jest.mock("../cfetch", () => {
10
- return jest.requireActual("./mock-cfetch");
11
- });
8
+ describe("wrangler", () => {
9
+ runInTempDir();
12
10
 
13
- async function w(cmd: void | string, options?: { tap: boolean }) {
14
- const tapped = options?.tap ? tap() : undefined;
15
- await main([...(cmd ? cmd.split(" ") : [])]);
16
- tapped?.off();
17
- return { stdout: tapped?.out, stderr: tapped?.err };
18
- }
19
-
20
- function tap() {
21
- const oldLog = console.log;
22
- const oldError = console.error;
23
-
24
- const toReturn = {
25
- off: () => {
26
- console.log = oldLog;
27
- console.error = oldError;
28
- },
29
- out: "",
30
- err: "",
31
- };
32
-
33
- console.log = (...args) => {
34
- toReturn.out += args.join("");
35
- oldLog.apply(console, args);
36
- // console.trace(...args); // use this if you want to find the true source of your console.log
37
- };
38
- console.error = (...args) => {
39
- toReturn.err += args.join("");
40
- oldError.apply(console, args);
41
- };
42
-
43
- return toReturn;
44
- }
11
+ describe("no command", () => {
12
+ it("should display a list of available commands", async () => {
13
+ const { stdout, stderr } = await runWrangler();
45
14
 
46
- describe("wrangler", () => {
47
- it("should run", async () => {
48
- const { stdout } = await w(undefined, { tap: true });
49
-
50
- expect(stdout).toMatchInlineSnapshot(`
51
- "wrangler
52
-
53
- Commands:
54
- wrangler init [name] 📥 Create a wrangler.toml configuration file
55
- wrangler dev <filename> 👂 Start a local server for developing your worker
56
- wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
57
- wrangler tail [name] 🦚 Starts a log tailing session for a deployed Worker.
58
- wrangler secret 🤫 Generate a secret that can be referenced in the worker script
59
- wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
60
- wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
61
- wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
62
- wrangler pages ⚡️ Configure Cloudflare Pages
63
-
64
- Flags:
65
- --config Path to .toml configuration file [string]
66
- --help Show help [boolean]
67
- --version Show version number [boolean]
68
-
69
- Options:
70
- --local Run on my machine [boolean] [default: false]"
71
- `);
72
- });
15
+ expect(stdout).toMatchInlineSnapshot(`
16
+ "wrangler
73
17
 
74
- describe("init", () => {
75
- const ogcwd = process.cwd();
18
+ Commands:
19
+ wrangler init [name] 📥 Create a wrangler.toml configuration file
20
+ wrangler dev <filename> 👂 Start a local server for developing your worker
21
+ wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
22
+ wrangler tail [name] 🦚 Starts a log tailing session for a deployed Worker.
23
+ wrangler secret 🤫 Generate a secret that can be referenced in the worker script
24
+ wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
25
+ wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
26
+ wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
27
+ wrangler pages ⚡️ Configure Cloudflare Pages
28
+
29
+ Flags:
30
+ -c, --config Path to .toml configuration file [string]
31
+ -h, --help Show help [boolean]
32
+ -v, --version Show version number [boolean]
33
+
34
+ Options:
35
+ -l, --local Run on my machine [boolean] [default: false]"
36
+ `);
76
37
 
77
- beforeEach(() => {
78
- process.chdir(path.join(__dirname, "fixtures", "init"));
38
+ expect(stderr).toMatchInlineSnapshot(`""`);
79
39
  });
40
+ });
41
+
42
+ describe("invalid command", () => {
43
+ it("should display an error", async () => {
44
+ const { error, stdout, stderr } = await runWrangler("invalid-command");
45
+
46
+ expect(stdout).toMatchInlineSnapshot(`""`);
47
+ expect(stderr).toMatchInlineSnapshot(`
48
+ "wrangler
49
+
50
+ Commands:
51
+ wrangler init [name] 📥 Create a wrangler.toml configuration file
52
+ wrangler dev <filename> 👂 Start a local server for developing your worker
53
+ wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
54
+ wrangler tail [name] 🦚 Starts a log tailing session for a deployed Worker.
55
+ wrangler secret 🤫 Generate a secret that can be referenced in the worker script
56
+ wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
57
+ wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
58
+ wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
59
+ wrangler pages ⚡️ Configure Cloudflare Pages
80
60
 
81
- afterEach(async () => {
82
- await fsp.rm("./wrangler.toml");
83
- process.chdir(ogcwd);
61
+ Flags:
62
+ -c, --config Path to .toml configuration file [string]
63
+ -h, --help Show help [boolean]
64
+ -v, --version Show version number [boolean]
65
+
66
+ Options:
67
+ -l, --local Run on my machine [boolean] [default: false]
68
+
69
+ Unknown command: invalid-command."
70
+ `);
71
+ expect(error).toMatchInlineSnapshot(
72
+ `[Error: Unknown command: invalid-command.]`
73
+ );
84
74
  });
75
+ });
85
76
 
77
+ describe("init", () => {
86
78
  it("should create a wrangler.toml", async () => {
87
- await w("init");
79
+ mockConfirm({
80
+ text: "No package.json found. Would you like to create one?",
81
+ result: false,
82
+ });
83
+ await runWrangler("init");
88
84
  const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
89
85
  expect(typeof parsed.compatibility_date).toBe("string");
86
+ expect(fs.existsSync("./package.json")).toBe(false);
87
+ expect(fs.existsSync("./tsconfig.json")).toBe(false);
90
88
  });
91
89
 
92
- it("should error when wrangler.toml already exists", async () => {
93
- fs.closeSync(fs.openSync("./wrangler.toml", "w"));
94
- const { stderr } = await w("init", { tap: true });
95
- expect(stderr.endsWith("wrangler.toml already exists.")).toBe(true);
90
+ it("should display warning when wrangler.toml already exists, and exit if user does not want to carry on", async () => {
91
+ fs.writeFileSync("./wrangler.toml", "", "utf-8");
92
+ mockConfirm({
93
+ text: "Do you want to continue initializing this project?",
94
+ result: false,
95
+ });
96
+ const { warnings } = await runWrangler("init");
97
+ expect(warnings).toContain("wrangler.toml file already exists!");
98
+ const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
99
+ expect(typeof parsed.compatibility_date).toBe("undefined");
96
100
  });
97
- });
98
101
 
99
- describe("kv:namespace", () => {
100
- afterAll(() => {
101
- unsetAllMocks();
102
+ it("should display warning when wrangler.toml already exists, but continue if user does want to carry on", async () => {
103
+ fs.writeFileSync("./wrangler.toml", "", "utf-8");
104
+ mockConfirm(
105
+ {
106
+ text: "Do you want to continue initializing this project?",
107
+ result: true,
108
+ },
109
+ {
110
+ text: "No package.json found. Would you like to create one?",
111
+ result: false,
112
+ }
113
+ );
114
+ const { warnings } = await runWrangler("init");
115
+ expect(warnings).toContain("wrangler.toml file already exists!");
116
+ const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
117
+ expect(typeof parsed.compatibility_date).toBe("string");
118
+ });
119
+
120
+ it("should create a package.json if none is found and user confirms", async () => {
121
+ mockConfirm(
122
+ {
123
+ text: "No package.json found. Would you like to create one?",
124
+ result: true,
125
+ },
126
+ {
127
+ text: "Would you like to use typescript?",
128
+ result: false,
129
+ }
130
+ );
131
+ await runWrangler("init");
132
+ expect(fs.existsSync("./package.json")).toBe(true);
133
+ const packageJson = JSON.parse(
134
+ fs.readFileSync("./package.json", "utf-8")
135
+ );
136
+ expect(packageJson.name).toEqual("worker"); // TODO: should we infer the name from the directory?
137
+ expect(packageJson.version).toEqual("0.0.1");
138
+ expect(fs.existsSync("./tsconfig.json")).toBe(false);
139
+ });
140
+
141
+ it("should not touch an existing package.json in the same directory", async () => {
142
+ mockConfirm({
143
+ text: "Would you like to use typescript?",
144
+ result: false,
145
+ });
146
+
147
+ fs.writeFileSync(
148
+ "./package.json",
149
+ JSON.stringify({ name: "test", version: "1.0.0" }),
150
+ "utf-8"
151
+ );
152
+
153
+ await runWrangler("init");
154
+ const packageJson = JSON.parse(
155
+ fs.readFileSync("./package.json", "utf-8")
156
+ );
157
+ expect(packageJson.name).toEqual("test");
158
+ expect(packageJson.version).toEqual("1.0.0");
102
159
  });
103
- let KVNamespaces: { title: string; id: string }[] = [];
104
- it("can create a namespace", async () => {
105
- setMock("/accounts/:accountId/storage/kv/namespaces", (uri, init) => {
106
- expect(init.method === "POST");
107
- const body = JSON.parse(init.body);
108
- expect(body.title).toBe("worker-UnitTestNamespace");
109
- KVNamespaces.push({ title: body.title, id: "some-namespace-id" });
110
- return { id: "some-namespace-id" };
160
+
161
+ it("should not touch an existing package.json in an ancestor directory", async () => {
162
+ mockConfirm({
163
+ text: "Would you like to use typescript?",
164
+ result: false,
111
165
  });
112
166
 
113
- await w("kv:namespace create UnitTestNamespace");
114
- expect(
115
- KVNamespaces.find((ns) => ns.title === `worker-UnitTestNamespace`)
116
- ).toBeTruthy();
167
+ fs.writeFileSync(
168
+ "./package.json",
169
+ JSON.stringify({ name: "test", version: "1.0.0" }),
170
+ "utf-8"
171
+ );
172
+
173
+ fs.mkdirSync("./sub-1/sub-2", { recursive: true });
174
+ process.chdir("./sub-1/sub-2");
175
+
176
+ await runWrangler("init");
177
+ expect(fs.existsSync("./package.json")).toBe(false);
178
+ expect(fs.existsSync("../../package.json")).toBe(true);
179
+
180
+ const packageJson = JSON.parse(
181
+ fs.readFileSync("../../package.json", "utf-8")
182
+ );
183
+ expect(packageJson.name).toEqual("test");
184
+ expect(packageJson.version).toEqual("1.0.0");
117
185
  });
118
186
 
119
- let createdNamespace: { id: string; title: string };
120
- it("can list namespaces", async () => {
121
- setMock(
122
- "/accounts/:accountId/storage/kv/namespaces\\?:qs",
123
- (uri, init) => {
124
- expect(init).toBe(undefined);
125
- return KVNamespaces;
187
+ it("should create a tsconfig.json and install `workers-types` if none is found and user confirms", async () => {
188
+ mockConfirm(
189
+ {
190
+ text: "No package.json found. Would you like to create one?",
191
+ result: true,
192
+ },
193
+ {
194
+ text: "Would you like to use typescript?",
195
+ result: true,
126
196
  }
127
197
  );
128
- const { stdout } = await w("kv:namespace list", { tap: true });
129
- const namespaces = JSON.parse(stdout);
130
- createdNamespace = namespaces.find(
131
- (ns) => ns.title === "worker-UnitTestNamespace"
198
+ await runWrangler("init");
199
+ expect(fs.existsSync("./tsconfig.json")).toBe(true);
200
+ const tsconfigJson = JSON.parse(
201
+ fs.readFileSync("./tsconfig.json", "utf-8")
202
+ );
203
+ expect(tsconfigJson.compilerOptions.types).toEqual([
204
+ "@cloudflare/workers-types",
205
+ ]);
206
+ const packageJson = JSON.parse(
207
+ fs.readFileSync("./package.json", "utf-8")
132
208
  );
133
- expect(createdNamespace.title).toBe("worker-UnitTestNamespace");
209
+ expect(packageJson.devDependencies).toEqual({
210
+ "@cloudflare/workers-types": expect.any(String),
211
+ });
134
212
  });
135
213
 
136
- it("can delete a namespace", async () => {
137
- const namespaceIdToDelete = createdNamespace.id;
138
- setMock(
139
- "/accounts/:accountId/storage/kv/namespaces/:namespaceId",
140
- (uri, init) => {
141
- expect(init.method).toBe("DELETE");
142
- KVNamespaces = KVNamespaces.filter(
143
- (ns) => ns.id !== namespaceIdToDelete
144
- );
145
- }
214
+ it("should not touch an existing tsconfig.json in the same directory", async () => {
215
+ fs.writeFileSync(
216
+ "./package.json",
217
+ JSON.stringify({ name: "test", version: "1.0.0" }),
218
+ "utf-8"
219
+ );
220
+ fs.writeFileSync(
221
+ "./tsconfig.json",
222
+ JSON.stringify({ compilerOptions: {} }),
223
+ "utf-8"
224
+ );
225
+
226
+ await runWrangler("init");
227
+ const tsconfigJson = JSON.parse(
228
+ fs.readFileSync("./tsconfig.json", "utf-8")
229
+ );
230
+ expect(tsconfigJson.compilerOptions).toEqual({});
231
+ });
232
+
233
+ it("should not touch an existing package.json in an ancestor directory", async () => {
234
+ fs.writeFileSync(
235
+ "./package.json",
236
+ JSON.stringify({ name: "test", version: "1.0.0" }),
237
+ "utf-8"
238
+ );
239
+ fs.writeFileSync(
240
+ "./tsconfig.json",
241
+ JSON.stringify({ compilerOptions: {} }),
242
+ "utf-8"
146
243
  );
147
- await w(`kv:namespace delete --namespace-id ${namespaceIdToDelete}`);
148
- expect(KVNamespaces.find((ns) => ns.id === namespaceIdToDelete)).toBe(
149
- undefined
244
+
245
+ fs.mkdirSync("./sub-1/sub-2", { recursive: true });
246
+ process.chdir("./sub-1/sub-2");
247
+
248
+ await runWrangler("init");
249
+ expect(fs.existsSync("./tsconfig.json")).toBe(false);
250
+ expect(fs.existsSync("../../tsconfig.json")).toBe(true);
251
+
252
+ const tsconfigJson = JSON.parse(
253
+ fs.readFileSync("../../tsconfig.json", "utf-8")
254
+ );
255
+ expect(tsconfigJson.compilerOptions).toEqual({});
256
+ });
257
+
258
+ it("should error if `--type` is used", async () => {
259
+ const { error } = await runWrangler("init --type");
260
+ expect(error).toMatchInlineSnapshot(
261
+ `[Error: The --type option is no longer supported.]`
150
262
  );
151
263
  });
264
+
265
+ it("should error if `--type javascript` is used", async () => {
266
+ const { error } = await runWrangler("init --type javascript");
267
+ expect(error).toMatchInlineSnapshot(
268
+ `[Error: The --type option is no longer supported.]`
269
+ );
270
+ });
271
+
272
+ it("should error if `--type rust` is used", async () => {
273
+ const { error } = await runWrangler("init --type rust");
274
+ expect(error).toMatchInlineSnapshot(
275
+ `[Error: The --type option is no longer supported.]`
276
+ );
277
+ });
278
+
279
+ it("should error if `--type webpack` is used", async () => {
280
+ const { error } = await runWrangler("init --type webpack");
281
+ expect(error).toMatchInlineSnapshot(`
282
+ [Error: The --type option is no longer supported.
283
+ If you wish to use webpack then you will need to create a custom build.]
284
+ `);
285
+ });
152
286
  });
153
287
  });
@@ -0,0 +1,22 @@
1
+ import { mockFetchInternal } from "./mock-cfetch";
2
+ import { confirm, prompt } from "../dialogs";
3
+ import { fetchInternal } from "../cfetch/internal";
4
+
5
+ jest.mock("../cfetch/internal");
6
+ (fetchInternal as jest.Mock).mockImplementation(mockFetchInternal);
7
+
8
+ jest.mock("../dialogs");
9
+
10
+ // By default (if not configured by mockConfirm()) calls to `confirm()` should throw.
11
+ (confirm as jest.Mock).mockImplementation(() => {
12
+ throw new Error(
13
+ "Unexpected call to `confirm()`. You should use `mockConfirm()` to mock calls to `confirm()` with expectations. Search the codebase for `mockConfirm` to learn more."
14
+ );
15
+ });
16
+
17
+ // By default (if not configured by mockPrompt()) calls to `prompt()` should throw.
18
+ (prompt as jest.Mock).mockImplementation(() => {
19
+ throw new Error(
20
+ "Unexpected call to `prompt()`. You should use `mockPrompt()` to mock calls to `prompt()` with expectations. Search the codebase for `mockPrompt` to learn more."
21
+ );
22
+ });