with one click
reviewing-unit-tests
// Use when reviewing Vitest unit-test diffs in ComfyUI_frontend, especially new mocks, store tests, component tests, or bugfix regression tests.
// Use when reviewing Vitest unit-test diffs in ComfyUI_frontend, especially new mocks, store tests, component tests, or bugfix regression tests.
Manages cherry-pick backports across stable release branches. Discovers candidates from Slack/git, analyzes dependencies, resolves conflicts via worktree, and logs results. Use when asked to backport, cherry-pick to stable, manage release branches, do stable branch maintenance, or run a backport session.
Bug fix workflow that proves test validity with a red-then-green CI sequence. Commits a failing test first (CI red), then the minimal fix (CI green). Use when fixing a bug, writing a regression test, or when asked to prove a fix works.
add, update, or remove a model page entry on the comfy org website. creates a PR to Comfy-Org/ComfyUI_frontend apps/website folder with the change and posts a Vercel preview link back to Slack.
Writes Playwright e2e tests for ComfyUI_frontend. Use when creating, modifying, or debugging browser tests. Triggers on: playwright, e2e test, browser test, spec file.
Ships performance fixes with CI-proven improvement using stacked PRs. PR1 adds a @perf test (establishes baseline on main), PR2 adds the fix (CI shows delta). Use when implementing a perf optimization and wanting to prove it in CI.
Diagnoses and fixes flaky Playwright e2e tests by replacing race-prone patterns with retry-safe alternatives. Use when triaging CI flakes, hardening spec files, fixing timing races, or asked to stabilize browser tests. Triggers on: flaky, flake, harden, stabilize, race condition in e2e, intermittent failure.
| name | reviewing-unit-tests |
| description | Use when reviewing Vitest unit-test diffs in ComfyUI_frontend, especially new mocks, store tests, component tests, or bugfix regression tests. |
Review for behavior and current repo rules, not motion. Compare to authoritative rules, not prior diffs or legacy snippets.
When docs and examples conflict, use this order:
docs/testing/vitest-patterns.mddocs/testing/unit-testing.md, docs/testing/store-testing.md, and docs/testing/component-testing.mdApply these repo-specific clarifications:
docs/testing/component-testing.md starts with the authoritative rule: new component tests use @testing-library/vue with @testing-library/user-event. The @vue/test-utils snippets below it are legacy examples.docs/testing/store-testing.md still contains as any examples. Treat them as legacy snippets, not approval for new or edited test code.| If you see... | Failure mode | Default action |
|---|---|---|
New @vue/test-utils import in a new component test | legacy test API | Request changes |
vi.mock('vue-i18n', ...) | mocked i18n | Request changes |
as any, @ts-expect-error, as Mock, as ReturnType<typeof vi.fn>, as unknown as X | unnecessary cast or type escape | Request changes unless the author proves no safer type exists |
getXMock(), renamed wrapper, or helper that only returns a mocked value | alias-by-renaming | Request changes |
beforeEach recreates the return object for a module-mocked composable or service | shared mock setup drift | Request changes |
| Assertions only check defaults, mock plumbing, or CSS hooks | non-behavioral test | Request changes |
| Bugfix test has no proof it fails on pre-fix code | unproven regression | Request changes |
| Excuse | Reality |
|---|---|
| "I restructured the mocks" | If the indirection stayed, nothing improved. Flag alias-by-renaming. |
| "The docs do it" | Rule, note, and lint beat legacy snippet. Compare to the current rule, not the nearest example. |
| "TypeScript required the cast" | vi.mocked() usually narrows mock methods. Assertion-only references need no cast. |
"Putting it in beforeEach is DRY" | Recreating module mock state in hooks hides singleton behavior and drifts from the documented pattern. |
| "It is only a nit" | Explicit repo-rule violations are never nits. |
| "No behavior changed, just cleanup" | Motion != fix. Ask what behavior got stronger. |
| "Mental revert is enough" | For bugfix tests, establish red on pre-fix code or ask the author to show it. |
vi.mock() factory. Access it per test via the composable itself. See docs/testing/unit-testing.md "Mocking Composables with Reactive State".vi.spyOn(...).createTestingPinia({ stubActions: false }) per docs/testing/vitest-patterns.md and docs/testing/store-testing.md.// Before
const mockAdd = vi.hoisted(() => vi.fn())
// After: same indirection, new name
function getToastAddMock() {
return useToast().add
}
If the wrapper only renames or relays a mocked value, fail it. Inline the lookup at the call site or fetch the singleton mock via the documented pattern.
vi.mocked() Scope| Use case | vi.mocked() required? |
|---|---|
.mockReturnValue, .mockResolvedValue, .mockImplementation | Yes |
.mock.calls, .mock.results | Yes |
expect(fn).toHaveBeenCalled() | No |
expect(fn).toHaveBeenCalledWith(...) | No |
vi.mocked() would narrow correctly.vi.mocked() around assertion-only references just for style.mockClear() or mockReset() when vi.clearAllMocks() or vi.resetAllMocks() already runs in the relevant hook chain.clearAllMocks vs resetAllMocks unless behavior depends on it.primevue/usetoast is usually acceptable.vue-i18nvue-i18n in component tests.createI18n per docs/testing/vitest-patterns.md and the shared testI18n setup.| Smell | Review bar |
|---|---|
| Change-detector test | Reject. Default values alone prove nothing. |
| Mock-only assertion | Accept collaborator-call assertions only when the call is the meaningful external effect and the test also exercises the triggering behavior. |
| Non-behavioral assertion | Reject tests that only check classes, utility hooks, or styling internals. |
New component test using @vue/test-utils | Request changes. Use @testing-library/vue plus @testing-library/user-event. |
any, as any, or @ts-expect-error in new or edited test code | Request changes unless the author proves no safer type exists. Legacy doc snippets do not authorize it. |
For fix: PRs or bugfix diffs:
A regression test that never proves red does not pin the bug.
LGTM, just one nit or approve and move on?.alias-by-renaming, unnecessary cast, mocked i18n, mock-only assertion, unproven regression.| When you see... | Read this |
|---|---|
New vi.mock(...) for a composable | docs/testing/unit-testing.md -> "Mocking Composables with Reactive State" |
| New store test or store mock | docs/testing/vitest-patterns.md setup + docs/testing/store-testing.md |
| New component test | Top note in docs/testing/component-testing.md |
vue-i18n in a component test | docs/testing/vitest-patterns.md + src/components/searchbox/v2/__test__/testUtils.ts |
| Cast around a mock | docs/guidance/typescript.md -> "Type Assertion Hierarchy" |
| Purpose | Path |
|---|---|
| Composable mocking patterns | docs/testing/unit-testing.md |
| Store testing patterns | docs/testing/store-testing.md |
| Repo-wide Vitest setup defaults | docs/testing/vitest-patterns.md |
| Component testing rule for new tests | docs/testing/component-testing.md |
| Real i18n setup | src/components/searchbox/v2/__test__/testUtils.ts |