Skip to content

Commit

Permalink
added view option
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Apr 26, 2024
1 parent 2d2d901 commit 5bcabe3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions docs/src/content/docs/getting-started/testing-scripts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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."]
}]
})
```
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions docs/src/content/docs/reference/cli/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Options:
-rmo, --remove-out remove output folder if it exists
--cli <string> override path to the cli
-tp, --test-provider <string> test provider
--view open test viewer once tests are executed
-h, --help display help for command
```

Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export async function cli() {
.option("-rmo, --remove-out", "remove output folder if it exists")
.option("--cli <string>", "override path to the cli")
.option("-tp, --test-provider <string>", "test provider")
.option("--view", "open test viewer once tests are executed")

const scripts = program
.command("scripts")
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function scriptsTest(
removeOut?: boolean
testProvider?: string
models?: string[]
view?: boolean
}
) {
const prj = await buildProject()
Expand Down Expand Up @@ -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)
}

0 comments on commit 5bcabe3

Please sign in to comment.