From 85e83f96f509399d3fa4a9766e3fa706f1f1cae9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Aug 2026 04:51:42 +0000 Subject: [PATCH] =?UTF-8?q?docs:=20=E5=85=A5=E9=97=A8=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=94=B9=E6=95=99=E4=BB=93=E6=A0=B9=E8=B7=91=E6=B3=95,?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=8E=A8=E8=8D=90=E4=BC=9A=E5=81=87=E7=BB=BF?= =?UTF-8?q?=E7=9A=84=20pnpm=20--filter=20PKG=20test=20(#3442)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QUICK_REFERENCE.md 和 skills/objectui/guides/project-setup.md 两处入门文档, 把 #3378 那条会静默假绿的调用当推荐用法写着。按该机制,vitest 的 root 落在包 目录,根级 unit/dom/dom-heavy 三个 project 的 include 相对它匹配不到任何文件, 只有以绝对路径引入的 apps/console project 仍解析成功 —— 跑的是 console 的 22 个文件、报绿,注释声称的那个包一个都没跑。 PR #3437 合并后 vitest.config.mts 的 invocation guard 会让这些命令直接非零退出, 所以文档教的命令现在不只是误导,而是根本跑不通。三处全部换成仓根跑法,并把 guard 实际打印的正确跑法摘录进来,便于读者在别处撞见该错误框时认得出。 - QUICK_REFERENCE.md: --filter console test / --filter core test 两行 → pnpm exec vitest run packages/core/ | apps/console/ | packages/core/src/.test.ts - project-setup.md: --filter core test 一行 → 同上(单独拆出 Scoped tests 段, 因为它和同块的 --filter build / --filter dev 不同,不能用 --filter 表达) 单文件示例一律写成 占位符:guard 的 missing-path-filter 分支会拒绝指向 不存在文件的具体路径,写个看似真实的 x.test.ts 反而会被拒。 content/docs/guide/plugin-development.md:422 本就是正确形状,未改动。 与 #3240(包级 test 脚本存废)无关 —— 无论存废,文档都该教仓根跑法。 Fixes #3442 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt --- QUICK_REFERENCE.md | 30 +++++++++++++++++++++---- skills/objectui/guides/project-setup.md | 27 +++++++++++++++++++++- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/QUICK_REFERENCE.md b/QUICK_REFERENCE.md index 0cc5c16f60..512d0c9433 100644 --- a/QUICK_REFERENCE.md +++ b/QUICK_REFERENCE.md @@ -21,13 +21,35 @@ pnpm --filter @object-ui/site dev # Docs site at http://localhost:3000 ### Test +Always run vitest **from the repo root**, with paths written relative to it and **no +`--`** before them: + ```bash -pnpm test # Run every vitest project -pnpm --filter @object-ui/console test # Run just the console tests -pnpm --filter @object-ui/core test # Run a single package's tests -pnpm playwright test # End-to-end tests +pnpm test # Run every vitest project (CI runs this) +pnpm exec vitest run packages/core/ # Run a single package's tests +pnpm exec vitest run packages/core/src/.test.ts # Run a single test file +pnpm exec vitest run apps/console/ # Run just the console tests +pnpm playwright test # End-to-end tests +``` + +Not `pnpm --filter test`, not `turbo run test`, not `cd packages/x && pnpm exec +vitest`, and never a path behind `--`. Each of those moved vitest's root into a package, +where the root `unit`/`dom`/`dom-heavy` projects match nothing and only `apps/console` +resolves: 22 foreign files passed, your package never ran, output green +(objectui#3378/#3288). A guard in `vitest.config.mts` now **exits non-zero** on all of +them and prints the correct invocation: + +``` +vitest 调用被拒绝:从包目录跑 vitest 会静默跑错测试集 (objectui#3378) +... +正确跑法 —— 一律在【仓库根目录】执行,路径前【不要】加 `--`: + pnpm exec vitest run packages//src/.test.ts # 只跑一个文件 + pnpm exec vitest run packages// # 只跑一个包 + pnpm test # 全量(CI 跑的就是它) ``` +Details in [AGENTS.md](./AGENTS.md) (“怎么跑测试”) and `scripts/vitest-invocation-guard.mjs`. + ### Run Examples ```bash diff --git a/skills/objectui/guides/project-setup.md b/skills/objectui/guides/project-setup.md index 7a27e8adb7..ea151170b3 100644 --- a/skills/objectui/guides/project-setup.md +++ b/skills/objectui/guides/project-setup.md @@ -306,9 +306,12 @@ pnpm type-check # TypeScript check all # Scoped commands pnpm --filter @object-ui/core build # Build single package -pnpm --filter @object-ui/core test # Test single package pnpm --filter "apps/*" dev # Dev all apps +# Scoped tests — always from the repo root, paths relative to it, no `--` +pnpm exec vitest run packages/core/ # Test single package +pnpm exec vitest run packages/core/src/.test.ts # Test single file + # Setup from clean clone ./scripts/setup.sh # Full automated setup # Or manually: @@ -317,6 +320,28 @@ pnpm build pnpm test ``` +Note that tests are scoped by a **path filter from the repo root**, not by +`pnpm --filter test`. The `--filter` form (and `turbo run test`, and +`cd packages/x && pnpm exec vitest`) makes vitest treat the package directory as its +root: the root-level `unit`/`dom`/`dom-heavy` projects declare their `include` globs +relative to that root and match nothing, while the `apps/console` project — brought in +by absolute path — still resolves. The run then executes console's 22 files, reports +`Test Files 22 passed (22)`, and never touches the package you asked for. A guard in +`vitest.config.mts` rejects those invocations with a non-zero exit and prints the +correct form: + +``` +vitest 调用被拒绝:从包目录跑 vitest 会静默跑错测试集 (objectui#3378) +... +正确跑法 —— 一律在【仓库根目录】执行,路径前【不要】加 `--`: + pnpm exec vitest run packages//src/.test.ts # 只跑一个文件 + pnpm exec vitest run packages// # 只跑一个包 + pnpm test # 全量(CI 跑的就是它) +``` + +The same guard rejects a path placed behind `--` (`pnpm --filter test -- +--run `), which pnpm forwards verbatim and vitest's CLI parser discards. + ### Adding a workspace package as dependency ```bash