> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qawolf.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Reference

> Reference for @qawolf/flows/cli, the Node-based entry point for headless flows that handle setup, teardown, notifications, and file work.

`@qawolf/flows/cli` is the smallest platform entry point in `@qawolf/flows`. CLI flows run in Node and have no browser or mobile driver. Use them for work that needs to coordinate with other flows in a run but doesn't require UI interaction — data setup, teardown, sending notifications, or processing files.

Because CLI flows run in Node, you can use the Node standard library directly for file, process, and network work:

```ts theme={null}
import { flow } from "@qawolf/flows/cli";
import { readFile } from "node:fs/promises";

export default flow("Read build metadata", "Basic", async ({ test }) => {
  await test("read metadata", async () => {
    const metadata = await readFile("build-metadata.json", "utf8");
    console.log(JSON.parse(metadata));
  });
});
```

## Primary Exports

* `flow(...)`
* `expect`
* `testContextDependencies`

It also exports CLI-specific target, callback context, and flow definition types.

Example:

```ts theme={null}
import { flow } from "@qawolf/flows/cli";

export default flow(
  "Prepare release metadata",
  "Basic",
  async ({ inputs, setOutput, test }) => {
    await test("create release payload", async () => {
      setOutput("RELEASE", {
        generatedAt: new Date().toISOString(),
        inputs,
        status: "ready",
      });
    });
  },
);
```

## Target Model

The current target type is:

```ts theme={null}
type CliFlowTarget = "Basic";
```

Accepted flow target input:

```ts theme={null}
type CliFlowTargetInput = CliFlowTarget | { target: CliFlowTarget };
```

Example:

```ts theme={null}
import { flow } from "@qawolf/flows/cli";

export const stringTargetFlow = flow("String target", "Basic", async () => {});

export const objectTargetFlow = flow(
  "Object target",
  { target: "Basic" },
  async () => {},
);
```

## Flow Callback Context

The callback receives the CLI flow context.

Public callback parameters:

* `inputs` — values published by an upstream flow in the same run
* `setOutput(...)` — publishes values for downstream flows to read
* `test(...)` — wraps named sub-steps that appear in your results

CLI flows do not receive `page`, `driver`, or any other launch object.

<Note>
  `test(...)` can be omitted for simple flows where grouping steps into named sub-steps doesn't add value. For most flows, wrapping steps in `test(...)` is recommended — the label appears in your results and makes failures easier to locate.
</Note>

Example:

```ts theme={null}
import { flow } from "@qawolf/flows/cli";

export default flow(
  "Prepare release metadata",
  "Basic",
  async ({ inputs, setOutput, test }) => {
    await test("create release payload", async () => {
      setOutput("RELEASE", {
        generatedAt: new Date().toISOString(),
        inputs,
        status: "ready",
      });
    });
  },
);
```

See [Passing data between flows](/qawolf/Pass-data-between-flows-29d5b2a994fb801080bce743ab552931) for how to use `inputs` and `setOutput` to coordinate with other flows in a run.

## `testContextDependencies`

`testContextDependencies` is exported for runner and tooling integration. Flow authors should usually use the public callback parameters above instead of depending on the raw runner dependency list.

## `expect`

The exported `expect` is a re-export of the [`expect`](https://www.npmjs.com/package/expect) package — the same assertion library Jest uses. Use Jest's [`expect` reference](https://jestjs.io/docs/expect) for the full matcher list (`toBe`, `toEqual`, `toMatchObject`, `toThrow`, etc.).

Always import `expect` from `@qawolf/flows/cli` rather than from `expect` or `jest` directly, so that future QA Wolf extensions stay in effect.

Example:

```ts theme={null}
import { expect, flow } from "@qawolf/flows/cli";

export default flow("Validate release payload", "Basic", async ({ inputs, test }) => {
  await test("payload has expected shape", async () => {
    expect(inputs).toMatchObject({
      status: "ready",
      generatedAt: expect.any(String),
    });
  });
});
```
