mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-27 08:25:50 +00:00
## Summary - Drop the `--` separator from all in-repo `pnpm test:unit -- <args>` examples. The separator is unnecessary (pnpm forwards extra args automatically) and on Windows PowerShell it mangles quoted args like `-t "restores host values by input name"`, splitting them into multiple tokens. - Add a short note in `docs/guidance/vitest.md` explaining the substring-match semantics of the positional filter and that `-t` matches `it()`/`test()` names only (not `describe()` blocks). - Fix `pnpm test:unit -- run <files>` in the backport-management skill: because `test:unit` is already `vitest run`, the literal `run` token was a positional path filter that silently narrowed the suite to files whose paths contain "run". ## Test plan - [ ] `pnpm test:unit useConflictAcknowledgment` matches `useConflictAcknowledgment.test.ts` - [ ] `pnpm test:unit SubgraphWidgetPromotion.test.ts -t "restores host values"` filters to a single test - [ ] `git grep "pnpm test:unit -- "` returns no in-repo matches
1.3 KiB
1.3 KiB
globs
| globs | |
|---|---|
|
Vitest Unit Test Conventions
See docs/testing/*.md for detailed patterns.
Test Quality
- Do not write change detector tests (tests that just assert defaults)
- Do not write tests dependent on non-behavioral features (styles, classes)
- Do not write tests that just test mocks - ensure real code is exercised
- Be parsimonious; avoid redundant tests
Mocking
- Use Vitest's mocking utilities (
vi.mock,vi.spyOn) - Keep module mocks contained - no global mutable state
- Use
vi.hoisted()for per-test mock manipulation - Don't mock what you don't own
Component Testing
- Use
@testing-library/vuewith@testing-library/user-eventfor component tests (an ESLint rule bans@vue/test-utilsin new tests) - Follow advice about making components easy to test
- Wait for reactivity with
await nextTick()after state changes
Running Tests
pnpm test:unit # Run all unit tests
pnpm test:unit path/to/file # Filter by substring of test file path
pnpm test:unit foo.test.ts -t "name" # Filter by test name (regex; it()/test() only, not describe())
Do not use the -- separator before vitest args; pnpm forwards extra args automatically, and -- mangles quoted args (e.g. -t "two words") on Windows PowerShell.