From 5bcabe315f0fee70eb2d709efe75fd2ab45a64f8 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Fri, 26 Apr 2024 14:13:40 -0700 Subject: [PATCH] added view option --- docs/src/content/docs/getting-started/testing-scripts.mdx | 7 ++++--- docs/src/content/docs/reference/cli/commands.md | 1 + packages/cli/src/cli.ts | 1 + packages/cli/src/test.ts | 5 ++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/src/content/docs/getting-started/testing-scripts.mdx b/docs/src/content/docs/getting-started/testing-scripts.mdx index f4963978ab..11286c6bab 100644 --- a/docs/src/content/docs/getting-started/testing-scripts.mdx +++ b/docs/src/content/docs/getting-started/testing-scripts.mdx @@ -20,8 +20,9 @@ The tests are added as an array of objects in the `tests` key of the `script` fu scripts({ ..., tests: [{ - files: "src/rag/markdown.md", - rubrics: "is a report with a list of issues" + files: "src/rag/testcode.ts", + rubrics: "is a report with a list of issues", + facts: ["The report says that the input string should be validated before use."] }] }) ``` @@ -31,7 +32,7 @@ scripts({ You can use the cli to run the tests for one or more scripts. ```sh -npx genaiscript test [script] +npx genaiscript test proofreader ``` If `script` is not provided, all scripts with tests will be tested. diff --git a/docs/src/content/docs/reference/cli/commands.md b/docs/src/content/docs/reference/cli/commands.md index 26f5dbec25..80fa62aa8d 100644 --- a/docs/src/content/docs/reference/cli/commands.md +++ b/docs/src/content/docs/reference/cli/commands.md @@ -104,6 +104,7 @@ Options: -rmo, --remove-out remove output folder if it exists --cli override path to the cli -tp, --test-provider test provider + --view open test viewer once tests are executed -h, --help display help for command ``` diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index a9e8354707..564e1adaa1 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -174,6 +174,7 @@ export async function cli() { .option("-rmo, --remove-out", "remove output folder if it exists") .option("--cli ", "override path to the cli") .option("-tp, --test-provider ", "test provider") + .option("--view", "open test viewer once tests are executed") const scripts = program .command("scripts") diff --git a/packages/cli/src/test.ts b/packages/cli/src/test.ts index f585eddafb..3bc7184ea1 100644 --- a/packages/cli/src/test.ts +++ b/packages/cli/src/test.ts @@ -32,6 +32,7 @@ export async function scriptsTest( removeOut?: boolean testProvider?: string models?: string[] + view?: boolean } ) { const prj = await buildProject() @@ -83,5 +84,7 @@ export async function scriptsTest( exec.pipeStdout(process.stdout) exec.pipeStderr(process.stdout) const res = await exec - process.exit(res.exitCode) + + if (options.view) await execa("npx", ["--yes", "promptfoo@latest", "view", "-y"]) + else process.exit(res.exitCode) }