Skip to content
Open
Changes from all commits
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
30 changes: 25 additions & 5 deletions docs/src/content/docs/development/Guides/tests.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
---
title: Writing Tests
lastUpdated: 2026-02-20
lastUpdated: 2026-07-13
---

## Frontend Tests

We use `vitest` to run the frontend tests. (See [vite.config.ts](https://github.com/invoke-ai/InvokeAI/blob/main/invokeai/frontend/web/vite.config.mts) for the default `vitest` options.)

{/* TODO: Finish frontend tests docs */}
Below are some common frontend test commands:

```bash
# From the repository root, run the frontend test suite once using the Makefile shortcut.
make frontend-test

# From the repository root, run the full frontend test suite in watch mode.
pnpm --dir invokeai/frontend/web test

# Run the frontend test suite once without watch mode.
pnpm --dir invokeai/frontend/web test:no-watch

# Equivalent one-shot command using the underlying Vitest subcommand.
pnpm --dir invokeai/frontend/web test:run

# Open the Vitest UI and collect coverage data while running tests.
pnpm --dir invokeai/frontend/web test:ui
```

If you are already working from `invokeai/frontend/web`, you can omit the `--dir` flag and run the same `pnpm` scripts directly from that directory.

## Backend Tests

Expand All @@ -27,6 +46,9 @@ As a rule of thumb, tests should be marked as 'slow' if there is a chance that t
Below are some common test commands:

```bash
# Run the fast tests from the repository root using the Makefile shortcut.
make test

# Run the fast tests. (This implicitly uses the configured default option: `-m "not slow"`.)
pytest tests/

Expand All @@ -45,9 +67,7 @@ pytest tests -m ""

### Test Organization

All backend tests are in the [`tests/`](https://github.com/invoke-ai/InvokeAI/tree/main/tests) directory. This directory mirrors the organization of the `invokeai/` directory. For example, tests for `invokeai/model_management/model_manager.py` would be found in `tests/model_management/test_model_manager.py`.

TODO: The above statement is aspirational. A re-organization of legacy tests is required to make it true.
Most backend tests live in the [`tests/`](https://github.com/invoke-ai/InvokeAI/tree/main/tests) directory. When adding a new backend test, prefer keeping it near the corresponding module area so related code and tests stay easy to find together.

### Tests that depend on models

Expand Down
Loading