From 7d3ad38e703c66dd83f74b082451da247565a51d Mon Sep 17 00:00:00 2001 From: wunianze666-netizen Date: Fri, 19 Jun 2026 00:42:28 +0800 Subject: [PATCH 1/2] expand testing guide with frontend commands --- .../content/docs/development/Guides/tests.mdx | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/src/content/docs/development/Guides/tests.mdx b/docs/src/content/docs/development/Guides/tests.mdx index c2dfd52b98c..4b581c95ea8 100644 --- a/docs/src/content/docs/development/Guides/tests.mdx +++ b/docs/src/content/docs/development/Guides/tests.mdx @@ -1,13 +1,31 @@ --- title: Writing Tests -lastUpdated: 2026-02-20 +lastUpdated: 2026-06-19 --- ## 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 */} +Frontend tests live alongside the code they exercise in the [`invokeai/frontend/web/src/`](https://github.com/invoke-ai/InvokeAI/tree/main/invokeai/frontend/web/src) tree. Test files typically use the `*.test.ts` or `*.test.tsx` naming pattern. + +Below are some common frontend test commands: + +```bash +# 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 @@ -47,7 +65,7 @@ pytest tests -m "" 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. +Some legacy tests still live outside this idealized structure, so use the example above as the preferred pattern for new tests rather than a guarantee about every existing file. ### Tests that depend on models From 6846d2b3e25a7da7f55b59c2d284cd478bb3f489 Mon Sep 17 00:00:00 2001 From: wunianze666-netizen Date: Mon, 13 Jul 2026 03:57:12 +0800 Subject: [PATCH 2/2] docs: align testing guide with reviewer feedback --- docs/src/content/docs/development/Guides/tests.mdx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/src/content/docs/development/Guides/tests.mdx b/docs/src/content/docs/development/Guides/tests.mdx index 4b581c95ea8..3e501738247 100644 --- a/docs/src/content/docs/development/Guides/tests.mdx +++ b/docs/src/content/docs/development/Guides/tests.mdx @@ -1,17 +1,18 @@ --- title: Writing Tests -lastUpdated: 2026-06-19 +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.) -Frontend tests live alongside the code they exercise in the [`invokeai/frontend/web/src/`](https://github.com/invoke-ai/InvokeAI/tree/main/invokeai/frontend/web/src) tree. Test files typically use the `*.test.ts` or `*.test.tsx` naming pattern. - 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 @@ -45,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/ @@ -63,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`. - -Some legacy tests still live outside this idealized structure, so use the example above as the preferred pattern for new tests rather than a guarantee about every existing file. +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