Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add args option
  • Loading branch information
c4spar committed Apr 3, 2023
commit 08320ba66fd952a260b4fe7ac61204e8f5bc9932
6 changes: 4 additions & 2 deletions prompt/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface AssertPromptSnapshotOptions {
meta: ImportMeta;
tests: Record<string, Array<string>>;
osSuffix?: Array<typeof Deno.build.os>;
args?: Array<string>;
fn(): Promise<unknown>;
}

Expand Down Expand Up @@ -85,7 +86,7 @@ function registerTest(options: AssertPromptSnapshotOptions) {
await ctx.step({
name,
async fn() {
const output: string = await runPrompt(options.meta.url, inputs);
const output: string = await runPrompt(options.meta.url, inputs, options.args);
const suffix = options.osSuffix?.includes(Deno.build.os)
? `.${Deno.build.os}`
: "";
Expand All @@ -103,14 +104,15 @@ function registerTest(options: AssertPromptSnapshotOptions) {
async function runPrompt(
url: string,
inputs: Array<string>,
args?: Array<string>,
): Promise<string> {
const cmd = new Deno.Command("deno", {
stdin: "piped",
stdout: "piped",
stderr: "piped",
args: [
"run",
"--allow-all",
...args ?? [],
url,
],
env: {
Expand Down