mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-06-19 19:30:29 +08:00
- README: add a visible ## Security section (official sources, vuln reporting via SECURITY.md, GateGuard/IOC/AgentShield guardrails, security guide); make stats line a plain paragraph to clear MD028 - eslint: empty catch comment in run-with-flags.js; drop unneeded escape in github-coordination/parsing.js; remove unused execFileSync import in its test (#2236 follow-ups) - markdownlint: wrap bare URLs in rules/vue/*.md (#2250 follow-up) npm run lint green; full suite 2836/2836.
54 lines
2.0 KiB
Markdown
54 lines
2.0 KiB
Markdown
---
|
|
paths:
|
|
- "**/*.vue"
|
|
---
|
|
|
|
# Vue Testing
|
|
|
|
> This file extends [common/testing.md](../common/testing.md) with Vue specific content.
|
|
|
|
## Stack
|
|
|
|
- Vitest (Vite-native runner) plus `@vue/test-utils`. `create-vue` scaffolds `@vitejs/plugin-vue`.
|
|
- DOM environment via `happy-dom` or `jsdom`, set in `vite.config.ts` under `test.environment`.
|
|
|
|
## Rendering and Async
|
|
|
|
- `mount` for a full render. `shallowMount` to stub all child components.
|
|
- `trigger` and `setValue` return promises, `await` them.
|
|
- `flushPromises` flushes resolved promise handlers. `nextTick` settles the DOM after a state change.
|
|
|
|
## What to Test
|
|
|
|
- Test the public interface only: props, emitted events, slots, rendered output.
|
|
- Do not assert private state or internal methods, and do not rely solely on snapshots.
|
|
|
|
## Composables
|
|
|
|
- Composables that use only reactivity APIs unit-test directly: call the function, assert on the returned refs.
|
|
- Composables that use lifecycle hooks or `inject` must be tested through a host component.
|
|
|
|
## Pinia
|
|
|
|
- In components: `createTestingPinia()` from `@pinia/testing`, passed via `global.plugins`. Actions are stubbed by default, set `stubActions: false` to run them. `createSpy: vi.fn` is required under Vitest (no Jest globals).
|
|
- In isolation: `beforeEach(() => setActivePinia(createPinia()))` gives a fresh store per test and prevents state leakage.
|
|
|
|
## Mount Config
|
|
|
|
- `global.plugins`, `global.stubs` (stubs `Transition` / `TransitionGroup` by default), `global.mocks` (e.g. `$router`), `global.provide` (for `inject`, Symbol keys supported).
|
|
- `RouterLinkStub` stubs `router-link` without mounting a full router.
|
|
|
|
```ts
|
|
const wrapper = mount(AuctionCard, {
|
|
props: { id: 1 },
|
|
global: { plugins: [createTestingPinia({ createSpy: vi.fn })] },
|
|
})
|
|
await wrapper.find('button').trigger('click')
|
|
expect(wrapper.emitted('bid')).toBeTruthy()
|
|
```
|
|
|
|
## Reference
|
|
|
|
- ECC skills: `frontend-patterns`, `vite-patterns`.
|
|
- Docs: <https://test-utils.vuejs.org/api/> · <https://pinia.vuejs.org/cookbook/testing.html> · <https://vitest.dev/>
|