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

# Cost & Performance

> Understand cost and performance considerations when using TestSprite.

## Goals

Keep feedback fast and costs predictable while maintaining strong coverage.

## Cost Controls

* **Scope smartly**: Use `testScope: "diff"` for day-to-day iteration; target subsets with `testIds` for quick loops
* **Run frequency**: Schedule nightly full runs; run diffs on PRs; use `rerun` to validate fixes without re-planning
* **Reports-first**: Review reports to avoid unnecessary re-executions
* **Artifact retention**: Retain only what you need (screenshots/videos) for CI retention windows

## Performance Tips

* **Local readiness**: Ensure apps start quickly and are reachable on the specified `localPort`; pre-warm test data or seed databases for faster setup
* **Selector stability**: Prefer role/label-based selectors to reduce retries and timeouts
* **Parallelization**: Keep tests independent for parallel execution in CI
* **Deterministic data**: Use stable fixtures to avoid slow flaky retries

## Suggested Defaults

* **PRs**: diff scope, targeted `testIds` on critical changes
* **Main branch**: daily full run, artifact retention 7 days
* **Hotfixes**: focused reruns on impacted suites

## Useful Flows

Common code patterns for efficient test execution and cost optimization. Use these flows to target specific changes, run subsets, and quickly validate fixes without full regeneration.

<CodeGroup>
  ```javascript Diff-only execution theme={null}
  testsprite_bootstrap_tests({ testScope: "diff", ... })
  ```

  ```javascript Subset during iteration theme={null}
  testsprite_generate_code_and_execute({ testIds: ["TC005", "TC010"] })
  ```

  ```javascript Rerun without re-planning theme={null}
  testsprite_rerun_tests({ projectPath: "/abs/path" })
  ```
</CodeGroup>

## Related

<Columns cols={2}>
  <Card title="Test Running & Monitoring" href="/mcp/core/continuous-monitoring">
    Learn about continuous monitoring and test execution
  </Card>

  <Card title="Modify or Update Tests" href="/mcp/core/modify-tests">
    Learn how to modify and update existing tests
  </Card>

  <Card title="MCP Tools Reference" href="/mcp/core/tools">
    Reference guide for MCP tools and commands
  </Card>

  <Card title="Healing & Observability" href="/mcp/concepts/healing-observability">
    Understand automatic healing and test observability
  </Card>
</Columns>
