@mrciphersmith/keryx 0.4.29 → 0.4.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/cli.js +2446 -1391
  2. package/dist/core.js +90 -27
  3. package/dist/keryx-general-worker-entry.js +82 -25
  4. package/package.json +1 -1
  5. package/src/gdskills/bundled/install-manifest.json +2 -0
  6. package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
  7. package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
  8. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +21 -3
  9. package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
  10. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -49
  11. package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
  12. package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
  13. package/src/gdskills/bundled/rules/core/error-handling.mdc +7 -8
  14. package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
  15. package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
  16. package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
  17. package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
  18. package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
  19. package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
  20. package/src/gdskills/bundled/rules/core/solid-principles.mdc +31 -7
  21. package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
  22. package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
  23. package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
  24. package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
  25. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +24 -60
  26. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +13 -65
  27. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +22 -35
  28. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +16 -309
  29. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +7 -21
  30. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +83 -227
  31. package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
  32. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +8 -8
  33. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +15 -37
  34. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +7 -7
  35. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +31 -66
  36. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +21 -39
  37. package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
  38. package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
  39. package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
  40. package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
  41. package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
  42. package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
  43. package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
  44. package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
  45. package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
  46. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
  47. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
  48. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
  49. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -84
  50. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
  51. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
  52. package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
  53. package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
  54. package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
  55. package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
  56. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
  57. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
  58. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
  59. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
  60. package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
  61. package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
  62. package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
  63. package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
  64. package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
  65. package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
  66. package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
  67. package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
  68. package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
  69. package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
  70. package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
  71. package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
  72. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +18 -37
  73. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
  74. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
  75. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
  76. package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
  77. package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
  78. package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
  79. package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
  80. package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
  81. package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
  82. package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
  83. package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
  84. package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
  85. package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
  86. package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
  87. package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
  88. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
  89. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
  90. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
  91. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
  92. package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
  93. package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
  94. package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
  95. package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
  96. package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
  97. package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
  98. package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
  99. package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
  100. package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
  101. package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
  102. package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
  103. package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
  104. package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +12 -45
  105. package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
  106. package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
  107. package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
  108. package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
  109. package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
  110. package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
  111. package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
  112. package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
  113. package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
  114. package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
  115. package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
  116. package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
  117. package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
  118. package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
  119. package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
  120. package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
  121. package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
  122. package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
  123. package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
@@ -7,78 +7,32 @@ metadata:
7
7
 
8
8
  # Vue patterns
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic design-pattern guidance to
11
- idiomatic Vue 3 Composition API design and its common anti-patterns.
12
- Applies to `*.vue` files and plain `*.ts` files alike (R1 review, PR #719,
13
- M4): a composable (`useX()`) is routinely a standalone `.ts` file, not a
14
- `.vue` SFC, and the reactivity/composable guidance below (`ref()` vs.
15
- `reactive()`, lifecycle-hook-in-composables rules, the return-shape rule)
16
- is exactly what a `.ts` composable needs — `ts-js-node`'s own generic
17
- patterns rule has no notion of Vue's reactivity primitives at all.
10
+ Narrows `core-common-rules`' design-pattern guidance to Vue 3 Composition API
11
+ design. Applies to `*.vue` and plain `*.ts` files (a composable is usually a
12
+ standalone `.ts` file).
18
13
 
19
14
  ## Reactivity
20
15
 
21
- - Use `ref()` for a single primitive or a value that is often reassigned
22
- wholesale; use `reactive()` for a fixed-shape object whose properties are
23
- mutated in place. Do not wrap a `reactive()` object in a `ref()` "for
24
- safety" -- pick one.
25
- - Never destructure a `reactive()` object or a raw (non-`defineProps`)
26
- props object into loose variables (`const { count } = state`) -- that
27
- copies the current value and breaks the reactive link. Use `toRefs()`
28
- (whole object) or `toRef()` (one property) when a template or composable
29
- needs individual reactive references out of a `reactive()` object.
30
- - Prefer a `computed()` over a `watch` that just re-derives and assigns a
31
- value on every dependency change; reach for `watch`/`watchEffect` only
32
- for a genuine side effect (a fetch, a DOM measurement, a log, syncing to
33
- an external system).
34
- - Give every `watch` an explicit, minimal source (`watch(() => props.id,
35
- ...)`, not `watch(props, ...)` with `{ deep: true }` when only one field
36
- actually needs to be observed) -- a whole-object deep watch fires on every
37
- unrelated field change and is expensive on large objects.
38
- - Stop a `watch`/`watchEffect` created outside a component's own setup
39
- scope (e.g. inside a manually managed subscription) using the stop handle
40
- it returns; one created directly inside `setup`/`<script setup>` is
41
- auto-stopped on unmount and needs no manual cleanup.
16
+ - `ref()` for a single primitive or a value often reassigned wholesale; `reactive()` for a fixed-shape object mutated in place. Do not wrap a `reactive()` object in a `ref()`.
17
+ - Never destructure a `reactive()` object or raw (non-`defineProps`) props object into loose variables; use `toRefs()` (whole object) or `toRef()` (one property).
18
+ - Prefer `computed()` over a `watch` that re-derives and assigns a value; use `watch`/`watchEffect` only for a side effect (fetch, DOM measurement, log, external sync).
19
+ - Give every `watch` an explicit, minimal source (`watch(() => props.id, ...)`), not `watch(props, ...)` with `{ deep: true }` for one field.
20
+ - Stop a `watch`/`watchEffect` created outside a component's setup scope with its returned stop handle; one inside `setup`/`<script setup>` needs none.
42
21
 
43
22
  ## Composables
44
23
 
45
- - Extract a composable (`useX()`) when the same stateful logic (a fetch +
46
- loading/error state, a subscription, a computed derivation) is needed in
47
- more than one component, instead of copy-pasting the `ref`/`watch` block.
48
- - Call composables that use lifecycle hooks (`onMounted`, `onUnmounted`,
49
- `provide`/`inject`) only from another composable or directly inside
50
- `setup`/`<script setup>` -- never from inside a callback, `watch`
51
- handler, or `async` continuation after an `await`, where the active
52
- component instance is no longer bound.
53
- - A composable returns refs/computed values and functions, not a plain
54
- object of dereferenced values -- return `{ count, increment }` (where
55
- `count` is the `ref` itself), not `{ count: count.value, increment }`,
56
- or the caller loses reactivity.
24
+ - Extract a composable (`useX()`) when the same stateful logic is needed in more than one component.
25
+ - Call a composable that uses lifecycle hooks (`onMounted`, `onUnmounted`, `provide`/`inject`) only from another composable or directly in `setup`/`<script setup>`, never from a callback, `watch` handler, or after an `await`.
26
+ - A composable returns the refs/computed values themselves and functions, `{ count, increment }`, not `{ count: count.value, increment }`.
57
27
 
58
28
  ## Component design
59
29
 
60
- - Emit an event (`emit('update:modelValue', v)`) instead of mutating a
61
- prop in place; a prop is one-way data flow from the parent, and Vue warns
62
- at runtime when a child writes to it directly.
63
- - Use `v-model` (or a named `v-model:propName`) for two-way bindable state
64
- instead of hand-wiring a prop plus a separately-named update event when
65
- the semantics are genuinely two-way.
66
- - Keep template `v-if`/`v-for` on the same element simple; when both are
67
- needed, wrap the `v-for` in a `<template>` with the `v-if` on each item,
68
- or filter the source list in a `computed()`, rather than relying on
69
- `eslint-plugin-vue`'s default precedence to make an implicit filter
70
- correct.
71
- - Prefer `provide`/`inject` for state genuinely shared down an arbitrary
72
- depth of the component tree (theme, current user); prop-drilling two or
73
- three levels does not need it, and a store (Pinia) is the better fit for
74
- state shared across unrelated branches of the tree.
30
+ - Emit an event (`emit('update:modelValue', v)`) instead of mutating a prop.
31
+ - Use `v-model` (or `v-model:propName`) for genuinely two-way state instead of a prop plus a separately named update event.
32
+ - When `v-if` and `v-for` are both needed, wrap the `v-for` in a `<template>` with `v-if` on each item, or filter in a `computed()`; do not rely on default precedence.
33
+ - `provide`/`inject` for state shared down an arbitrary depth (theme, current user); prop-drilling two or three levels does not need it; Pinia for state shared across unrelated branches.
75
34
 
76
35
  ## Anti-patterns
77
36
 
78
- - A `ref`/`reactive` object stored in module scope and mutated from
79
- multiple unrelated components as an ad hoc global store, instead of a
80
- Pinia store with named actions -- it works but loses devtools tracking,
81
- action naming, and testability.
82
- - A deeply nested `reactive()` object mutated from many call sites with no
83
- action layer -- prefer a Pinia store (or a composable with named mutator
84
- functions) so state changes have one discoverable entry point.
37
+ - A module-scope `ref`/`reactive` mutated from several unrelated components as an ad hoc global store, instead of a Pinia store with named actions.
38
+ - A deeply nested `reactive()` object mutated from many call sites with no action layer; use a Pinia store (or a composable with named mutators).
@@ -7,54 +7,24 @@ metadata:
7
7
 
8
8
  # Vue security
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic security rules to Vue-specific
11
- render-time and routing risks. Applies only to `*.vue` files; server-side
12
- Node.js concerns (request validation, dependency risk) still come from
10
+ Narrows `core-common-rules`' security rules to Vue render-time and routing
11
+ risks. Applies only to `*.vue`; server-side Node.js concerns come from
13
12
  `ts-js-node`'s security rule.
14
13
 
15
14
  ## Template injection (XSS)
16
15
 
17
- - Never bind `v-html` to a value that includes user-controlled or
18
- unsanitized content -- `v-html` renders raw HTML with no escaping, so a
19
- string containing `<script>`/`onerror=`/etc. executes. Sanitize with a
20
- library such as DOMPurify immediately before the `v-html` binding if raw
21
- HTML rendering is genuinely required, and keep the sanitize call next to
22
- the binding so it cannot be bypassed by a later edit.
23
- - Prefer interpolation (`{{ value }}`) or bound attributes (`:title="value"`)
24
- over `v-html` whenever the content is plain text -- both are
25
- auto-escaped by Vue's compiler, `v-html` is not.
26
- - Treat a dynamic `:href`/`:src` bound to user-controlled input as
27
- untrusted: reject or allowlist the scheme (`http:`/`https:`/`mailto:`)
28
- before binding it, since a `javascript:` URI in an anchor's `href` still
29
- executes on click.
30
- - Never pass a user-controlled string into `render()`'s `h()` calls as a
31
- raw HTML string; `h()` treats string children as text, but a manually
32
- constructed VNode tree that re-injects raw markup reintroduces the same
33
- risk `v-html` has.
16
+ - Never bind `v-html` to user-controlled or unsanitized content. If raw HTML is required, sanitize (e.g. DOMPurify) immediately before the binding and keep the call next to it.
17
+ - Prefer `{{ value }}` or `:title="value"` over `v-html` for plain text.
18
+ - Allowlist the scheme (`http:`/`https:`/`mailto:`) of a dynamic `:href`/`:src` bound to user-controlled input.
19
+ - Never pass a user-controlled string into `h()` as raw HTML, or re-inject raw markup through a hand-built VNode tree.
34
20
 
35
21
  ## Routing and SSR
36
22
 
37
- - Validate and narrow a Vue Router dynamic segment (`route.params.id`)
38
- before using it in a query, redirect target, or `v-html`-rendered value
39
- -- a route param is attacker-controlled input, not a trusted internal
40
- value.
41
- - In a server-rendered (Nuxt or custom SSR) app, never read a secret,
42
- session token, or unsanitized request header directly into a `ref`/
43
- `reactive()` value that gets serialized into the client-hydrated state --
44
- anything in the initial state payload is visible in the page source.
45
- - Guard a navigation guard's redirect target (`next('/somewhere')` or
46
- `router.push()`) built from a query parameter against open-redirect: only
47
- redirect to a same-origin, allowlisted path, never an unvalidated
48
- `redirect` query value passed straight through.
23
+ - Validate and narrow a Vue Router dynamic segment (`route.params.id`) before using it in a query, redirect target, or `v-html`-rendered value.
24
+ - In a server-rendered app (Nuxt or custom SSR), never read a secret, session token, or unsanitized request header into a `ref`/`reactive()` value serialized into client-hydrated state.
25
+ - Redirect from a navigation guard (`next('/somewhere')`, `router.push()`) to a query-derived target only if it is a same-origin, allowlisted path; never pass a raw `redirect` query value through.
49
26
 
50
27
  ## Store and state exposure
51
28
 
52
- - Do not store a raw auth token or other secret in a Pinia store field
53
- that is included in a `persist`/localStorage plugin without explicit
54
- review -- persisted store state survives in the browser's storage past
55
- the session and is readable by any script with DOM access on that
56
- origin.
57
- - Scope a Pinia store's `$reset()` (or manual reset) to run on logout for
58
- any store holding user-specific data, so a shared browser session (or a
59
- test suite reusing app state) does not leak the previous user's data
60
- into the next session.
29
+ - Do not store a raw auth token or other secret in a Pinia store field covered by a `persist`/localStorage plugin without explicit review.
30
+ - Reset (`$reset()` or manual) any Pinia store holding user-specific data on logout.
@@ -7,63 +7,31 @@ metadata:
7
7
 
8
8
  # Vue testing
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic testing rules to Vue component
11
- and composable testing with Vitest and Vue Test Utils. Applies only to
12
- `*.vue` files' own tests; a plain `.ts` composable's unit tests follow
13
- `ts-js-node`'s testing rule unless they mount a component.
10
+ Narrows `core-common-rules`' testing rules to Vue component and composable
11
+ testing with Vitest and Vue Test Utils. Applies to `*.vue` tests; a plain
12
+ `.ts` composable's unit tests follow `ts-js-node`'s testing rule unless they
13
+ mount a component.
14
14
 
15
15
  ## Layout and runner
16
16
 
17
- - Co-locate a component's test next to it (`OrderSummary.vue` /
18
- `OrderSummary.spec.ts` or the project's existing `__tests__` convention)
19
- -- match whatever the project already does rather than introducing a
20
- second layout.
21
- - Use the project's configured runner (Vitest is standard for Vue 3 /
22
- Vite projects) and its already-configured DOM environment (`happy-dom`
23
- or `jsdom`); do not add a second test runner or DOM environment for new
24
- tests.
25
- - Use `@vue/test-utils`'s `mount()` for a component that needs its full
26
- render tree and child components resolved, and `shallowMount()` only
27
- when child components are irrelevant to the behavior under test and
28
- stubbing them meaningfully reduces noise.
17
+ - Co-locate a component's test (`OrderSummary.spec.ts`) or use the project's `__tests__` convention; match the existing layout.
18
+ - Use the project's configured runner (Vitest) and DOM environment (`happy-dom` or `jsdom`); add no second runner or environment.
19
+ - Use `mount()` when the full render tree and child components are needed; `shallowMount()` only when child components are irrelevant to the behavior under test.
29
20
 
30
21
  ## Querying and interaction
31
22
 
32
- - Query by test id, role, or visible text (`wrapper.find('[data-testid=...]')`,
33
- or `@testing-library/vue`'s `getByRole`/`getByText` when the project uses
34
- it) instead of a CSS class or DOM structure selector that changes with
35
- styling.
36
- - Trigger user interaction through Test Utils' `trigger()` (`await
37
- wrapper.find(selector).trigger('click')`) or `@testing-library/vue`'s
38
- `fireEvent`, and `await` it -- Vue's DOM updates are asynchronous, so an
39
- un-awaited trigger asserts against stale DOM.
40
- - Assert on rendered output and emitted events (`wrapper.emitted('update')`),
41
- not on a component's internal reactive state reached through
42
- `wrapper.vm` -- `vm` access ties the test to implementation details that
43
- change without changing behavior.
23
+ - Query by test id, role, or visible text (`wrapper.find('[data-testid=...]')`, or `@testing-library/vue` `getByRole`/`getByText` if the project uses it), not a CSS class or structure selector.
24
+ - Trigger interaction with `trigger()` (or `@testing-library/vue`'s `fireEvent`) and `await` it.
25
+ - Assert on rendered output and emitted events (`wrapper.emitted('update')`), not internal state through `wrapper.vm`.
44
26
 
45
27
  ## Props, emits, and stores
46
28
 
47
- - Pass required props explicitly through `mount(Component, { props: {...}
48
- })`; do not rely on defaults silently covering a prop the test never
49
- sets when its value actually matters to the assertion.
50
- - Assert an emitted event with `wrapper.emitted('eventName')` and check
51
- the payload array, not just that the event fired -- a wrong payload is a
52
- real bug an emitted-only check misses.
53
- - For a component that uses Pinia, create a fresh test Pinia instance per
54
- test (`createTestingPinia()` from `@pinia/testing`, or `createPinia()` +
55
- `setActivePinia()`) rather than reusing one instance across tests, so
56
- store state from one test cannot leak into the next.
29
+ - Pass required props explicitly through `mount(Component, { props: {...} })`; do not let defaults cover a prop whose value matters to the assertion.
30
+ - Check the emitted payload array, not only that the event fired.
31
+ - For a Pinia component, create a fresh Pinia per test (`createTestingPinia()` from `@pinia/testing`, or `createPinia()` + `setActivePinia()`).
57
32
 
58
33
  ## Mocking and determinism
59
34
 
60
- - Mock network calls at the request boundary (the composable/service
61
- function, or MSW at the fetch layer) the project already uses, not deep
62
- inside a component's internals.
63
- - Use Vitest's fake timers (`vi.useFakeTimers()`) for a component that
64
- debounces, polls, or delays, and restore real timers afterward
65
- (`vi.useRealTimers()`) so later tests are not affected.
66
- - Flush pending reactivity updates with `await nextTick()` (or the
67
- awaited `trigger()`/`flushPromises()` the project already imports)
68
- before asserting on DOM that changes after an async composable call
69
- resolves, instead of adding an arbitrary `setTimeout` wait.
35
+ - Mock network at the request boundary (the composable/service function, or MSW at the fetch layer), not inside component internals.
36
+ - Use `vi.useFakeTimers()` for debounce/poll/delay, and restore with `vi.useRealTimers()`.
37
+ - Flush reactivity with `await nextTick()` (or the awaited `trigger()`/`flushPromises()` the project imports) before asserting on DOM that changes after an async call, not an arbitrary `setTimeout`.