Community编程与开发github.com

github/unit-test-vue-pinia

为 Vue 3 + TypeScript + Vitest + Pinia 代码库编写和审查单元测试。适用于创建或更新组件、组合式函数和 Store 的测试;使用 createTestingPinia 模拟 Pinia;应用 Vue Test Utils 模式;并强制执行黑盒断言而非实现细节。

unit-test-vue-pinia 是什么?

该技能专为 Vue 3 + TypeScript + Vitest + Pinia 代码库的单元测试编写与审查而设计。它帮助开发者创建或更新组件、组合式函数(composables)和 Pinia Store 的测试,利用 `createTestingPinia` 进行 Pinia 模拟,应用 Vue Test Utils 模式,并强制使用黑盒断言而非关注实现细节。支持平台包括 Claude Code、Cursor 和 Codex 等 AI 代理工具。核心优势在于引导开发者编写更健壮、可维护的测试,避免过度依赖内部实现,从而提升测试对重构的友好性。该技能通过解析项目中的测试文件和 Vue 生态标准实践,生成与现有风格一致的测试代码或提供审查建议。

兼容平台~Claude Code~Codex CLI~Cursor
Part ofReact
npx skills add https://github.com/github/awesome-copilot/tree/main/skills/unit-test-vue-pinia

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

unit-test-vue-pinia 是做什么的?

为 Vue 3 + TypeScript + Vitest + Pinia 代码库编写和审查单元测试。适用于创建或更新组件、组合式函数和 Store 的测试;使用 createTestingPinia 模拟 Pinia;应用 Vue Test Utils 模式;并强制执行黑盒断言而非实现细节。

主要功能

  • 组件测试:使用 Vue Test Utils 挂载组件,模拟依赖(如 Pinia Store),并通过用户交互断言预期行为。
  • 组合式函数测试:在受控环境下测试组合式函数的逻辑,通常借助 @vue/test-utils 中的 mount 或 shallowMount。
  • Pinia Store 测试:直接操作 Store 实例,测试状态、getter 和 action 的正确性,无需渲染组件。
  • 黑盒断言:鼓励通过外部可观察行为(如 HTML 输出、事件触发、函数调用)进行断言,而非检查内部状态或私有方法。

使用场景

  1. 为新功能添加单元测试时,自动生成符合 Vue 3 + TypeScript + Vitest + Pinia 规范的测试模板。
  2. 审查现有测试代码,指出常见问题如过度模拟、测试内部状态、缺少边界情况等。
  3. 重构过程中,确保单元测试保持有效,并提示需要更新的部分。

最佳实践

  • 始终使用 createTestingPinia 创建独立的测试环境,避免全局状态污染。
  • 优先通过组件的渲染输出和用户操作来验证行为,而非直接访问组件实例的内部状态。
  • 使用 vi.fn() 或 vi.spyOn() 模拟外部依赖,确保测试的隔离性。
  • 为每个测试用例提供清晰的命名,描述其验证的场景和预期结果。

支持的平台

  • Claude Code
  • Cursor
  • Codex
  • 其他兼容 AI 代理的 IDE 扩展

示例

以下是一个 Vue 组件测试的简单示例,使用 Vitest 和 Vue Test Utils:

<!-- MyComponent.vue -->
<template>
  <div>
    <p>{{ count }}</p>
    <button @click="increment">加一</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const count = ref(0)
const increment = () => count.value++
</script>
// MyComponent.spec.ts
import { mount } from '@vue/test-utils'
import { describe, it, expect } from 'vitest'
import { createTestingPinia } from '@pinia/testing'
import { useCounterStore } from '@/stores/counter'
import MyComponent from './MyComponent.vue'

describe('MyComponent', () => {
  it('点击按钮后计数增加', async () => {
    const wrapper = mount(MyComponent, {
      global: {
        plugins: [createTestingPinia()],
      },
    })

    const button = wrapper.find('button')
    await button.trigger('click')

    expect(wrapper.find('p').text()).toBe('1')
  })
})

配置要求

  • Vue 3
  • TypeScript
  • Vitest
  • Pinia
  • @vue/test-utils
  • @pinia/testing(可选,推荐)

通过遵循本技能的指导,您可以构建出更可靠、更易于维护的 Vue 3 应用程序测试套件。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

github/acquire-codebase-knowledge

Use this skill when the user explicitly asks to map, document, or onboard into an existing codebase. Trigger for prompts like "map this codebase", "document this architecture", "onboard me to this repo", or "create codebase docs". Do not trigger for routine feature implementation, bug fixes, or narrow code edits unless the user asks for repository-level discovery.

github/add-educational-comments

Add educational comments to the file specified, or prompt asking for file to comment if one is not provided.

github/agent-governance

Patterns and techniques for adding governance, safety, and trust controls to AI agent systems. Use this skill when: - Building AI agents that call external tools (APIs, databases, file systems) - Implementing policy-based access controls for agent tool usage - Adding semantic intent classification to detect dangerous prompts - Creating trust scoring systems for multi-agent workflows - Building audit trails for agent actions and decisions - Enforcing rate limits, content filters, or tool restrictions on agents - Working with any agent framework (PydanticAI, CrewAI, OpenAI Agents, LangChain, AutoGen)

github/agentic-eval

Patterns and techniques for evaluating and improving AI agent outputs. Use this skill when: - Implementing self-critique and reflection loops - Building evaluator-optimizer pipelines for quality-critical generation - Creating test-driven code refinement workflows - Designing rubric-based or LLM-as-judge evaluation systems - Adding iterative improvement to agent outputs (code, reports, analysis) - Measuring and improving agent response quality

github/agent-owasp-compliance

Check any AI agent codebase against the OWASP Agentic Security Initiative (ASI) Top 10 risks. Use this skill when: - Evaluating an agent system's security posture before production deployment - Running a compliance check against OWASP ASI 2026 standards - Mapping existing security controls to the 10 agentic risks - Generating a compliance report for security review or audit - Comparing agent framework security features against the standard - Any request like "is my agent OWASP compliant?", "check ASI compliance", or "agentic security audit"

github/ai-prompt-engineering-safety-review

Comprehensive AI prompt engineering safety review and improvement prompt. Analyzes prompts for safety, bias, security vulnerabilities, and effectiveness while providing detailed improvement recommendations with extensive frameworks, testing methodologies, and educational content.

github/appinsights-instrumentation

Instrument a webapp to send useful telemetry data to Azure App Insights

github/apple-appstore-reviewer

Serves as a reviewer of the codebase with instructions on looking for Apple App Store optimizations or rejection reasons.

github/architecture-blueprint-generator

Comprehensive project architecture blueprint generator that analyzes codebases to create detailed architectural documentation. Automatically detects technology stacks and architectural patterns, generates visual diagrams, documents implementation patterns, and provides extensible blueprints for maintaining architectural consistency and guiding new development.

github/arch-linux-triage

Triage and resolve Arch Linux issues with pacman, systemd, and rolling-release best practices.

github/arize-ai-provider-integration

Creates, reads, updates, and deletes Arize AI integrations that store LLM provider credentials used by evaluators and other Arize features. Supports any LLM provider (e.g. OpenAI, Anthropic, Azure OpenAI, AWS Bedrock, Vertex AI, Gemini, NVIDIA NIM). Use when the user mentions AI integration, LLM provider credentials, create integration, list integrations, update credentials, delete integration, or connecting an LLM provider to Arize.

github/arize-annotation

Creates and manages annotation configs (categorical, continuous, freeform label schemas) and annotation queues (human review workflows) on Arize. Applies human annotations to project spans via the Python SDK. Use when the user mentions annotation config, annotation queue, label schema, human feedback, bulk annotate spans, update_annotations, labeling queue, annotate record, or human review.

github/arize-dataset

Creates, manages, and queries Arize datasets and examples. Covers dataset CRUD, appending examples, exporting data, and file-based dataset creation using the ax CLI. Use when the user needs test data, evaluation examples, or mentions create dataset, list datasets, export dataset, append examples, dataset version, golden dataset, or test set.

github/arize-evaluator

Handles LLM-as-judge evaluation workflows on Arize including creating/updating evaluators, running evaluations on spans or experiments, managing tasks, trigger-run operations, column mapping, and continuous monitoring. Use when the user mentions create evaluator, LLM judge, hallucination, faithfulness, correctness, relevance, run eval, score spans, score experiment, trigger-run, column mapping, continuous monitoring, or improve evaluator prompt.

github/arize-experiment

Creates, runs, and analyzes Arize experiments for evaluating and comparing model performance. Covers experiment CRUD, exporting runs, comparing results, and evaluation workflows using the ax CLI. Use when the user mentions create experiment, run experiment, compare models, model performance, evaluate AI, experiment results, benchmark, A/B test models, or measure accuracy.

github/arize-instrumentation

Adds Arize AX tracing to an LLM application for the first time. Follows a two-phase agent-assisted flow to analyze the codebase then implement instrumentation after user confirmation. Use when the user wants to instrument their app, add tracing from scratch, set up LLM observability, integrate OpenTelemetry or openinference, or get started with Arize tracing.

github/arize-link

Generates deep links to the Arize UI for traces, spans, sessions, datasets, labeling queues, evaluators, and annotation configs. Produces clickable URLs for sharing Arize resources with team members. Use when the user wants to link to or open a trace, span, session, dataset, evaluator, or annotation config in the Arize UI.

github/arize-prompt-optimization

Optimizes, improves, and debugs LLM prompts using production trace data, evaluations, and annotations. Extracts prompts from spans, gathers performance signal, and runs a data-driven optimization loop using the ax CLI. Use when the user mentions optimize prompt, improve prompt, make AI respond better, improve output quality, prompt engineering, prompt tuning, or system prompt improvement.

github/arize-trace

Downloads, exports, and inspects existing Arize traces and spans to understand what an LLM app is doing or debug runtime issues. Covers exporting traces by ID, spans by ID, sessions by ID, and root-cause investigation using the ax CLI. Use when the user wants to look at existing trace data, see what their LLM app is doing, export traces, download spans, investigate errors, or analyze behavior regressions.

github/aspire

Aspire skill covering the Aspire CLI, AppHost orchestration, service discovery, integrations, MCP server, VS Code extension, Dev Containers, GitHub Codespaces, templates, dashboard, and deployment. Use when the user asks to create, run, debug, configure, deploy, or troubleshoot an Aspire distributed application.

相关技能