Skills tdd-vitest-typescript
📦

tdd-vitest-typescript

Content revision r1 High Risk ⚙️ External commands📁 Filesystem access

使用 Vitest 建置 TypeScript 測試

團隊常常很晚才加入測試,這會讓 TypeScript 回歸問題更難被捕捉。此技能會引導 Claude、Codex 和 Claude Code 進行測試優先的 Vitest 工作流程。

Supports: Claude Codex Code(CC)
Maintain this Skill? Claim it ⚠️ 38 Poor

Install with my Agent

Copy this request to your Agent. It includes the canonical Skill page and manifest.

Agent request
Review the Skillstore skill "tdd-vitest-typescript" from https://skillstore.io/skills/emz1998-tdd-vitest-typescript.md and its manifest at https://skillstore.io/api/skills/emz1998-tdd-vitest-typescript/manifest. Verify the artifact. Stop and obtain explicit user consent before installing or changing files.

Your Agent should still show its plan and request any confirmation required by the security policy.

Agent-readable resources

Use these links when an AI agent, crawler, or script needs clean context instead of reading the full page.

Test it

Using "tdd-vitest-typescript". 我需要針對計算機除法行為的測試。

Expected outcome:

此技能會識別成功案例和除以零案例,先撰寫失敗測試,然後引導最小實作。

Using "tdd-vitest-typescript". 我們的非同步使用者查詢測試不穩定。

Expected outcome:

此技能會用支援 promise 的斷言取代時間延遲,在測試之間重設 mock,並分離成功與失敗情境。

Using "tdd-vitest-typescript". 在重構前審查這些 Vitest 測試。

Expected outcome:

此技能會標示與實作耦合的斷言、建議以行為為核心的覆蓋範圍,並透過有意義的測試保護重構。

Security Audit

High Risk
v4 • 7/5/2026 Open versioned report

Most static findings are false positives from Markdown code fences, JavaScript template literals, and sample Vitest assertions. The setup script does have real external command and filesystem side effects, and it accepts an unvalidated target directory before writing generated files.

4
Files scanned
1,930
Lines analyzed
4
Review items
0
False positives ignored

Confirmed security concerns (1)

High
Unvalidated Project Path Can Redirect File Writes
The setup script accepts the target directory from process.argv[2], creates it recursively, changes into it, and writes project files. Absolute paths or parent-directory segments could place generated files outside the intended workspace.
The path comes directly from argv and is passed into existsSync, mkdirSync, and process.chdir before many writes. I found no normalization or rejection of absolute paths or parent traversal.
Capability review items (4)

These are real local capabilities that may be expected for this skill, so they require review but are not counted as confirmed malicious behavior.

High
Node.js child_process module
import { execSync } from 'child_process';
The setup script imports child_process so it can run external commands. The observed commands are setup-related and hardcoded, but this still gives the script package-manager execution capability.
High
Synchronous process execution
execSync(command, { stdio: 'inherit', ...options });
execSync runs npm init and npm install from the script, which can modify the workspace and trigger package-manager side effects. The command values are hardcoded, so the concern is execution capability rather than direct injection.
Medium
Synchronous file operations
writeFileSync(path, content.trim() + '\n');
writeFileSync is used by the project generator to create files such as configs, source files, tests, and README content. This is intended setup behavior, but it can overwrite files without prompting.
Medium
Synchronous file operations
writeFileSync('package.json', JSON.stringify(packageJson, null, 2) + '\n');
The script writes package.json after modifying scripts and module type. This is legitimate setup behavior, but it directly changes project metadata and can overwrite user configuration.

Risk Factors

⚙️ External commands (83)
references/advanced-patterns.md:473-476 references/advanced-patterns.md:491-495 references/advanced-patterns.md:495-512 references/anti-patterns.md:367-371 references/anti-patterns.md:371-375 scripts/setup-vitest.js:8 scripts/setup-vitest.js:17 scripts/setup-vitest.js:16 scripts/setup-vitest.js:21 scripts/setup-vitest.js:29 scripts/setup-vitest.js:50-67 scripts/setup-vitest.js:73-91 scripts/setup-vitest.js:101-120 scripts/setup-vitest.js:125-162 scripts/setup-vitest.js:183-187 scripts/setup-vitest.js:194-201 scripts/setup-vitest.js:201 scripts/setup-vitest.js:203 scripts/setup-vitest.js:206 scripts/setup-vitest.js:208 scripts/setup-vitest.js:211 scripts/setup-vitest.js:213 scripts/setup-vitest.js:216 scripts/setup-vitest.js:218 scripts/setup-vitest.js:228 scripts/setup-vitest.js:233 scripts/setup-vitest.js:237 scripts/setup-vitest.js:245 scripts/setup-vitest.js:252 SKILL.md:20-39 SKILL.md:39-45 SKILL.md:45-47 SKILL.md:47-60 SKILL.md:60-64 SKILL.md:64-66 SKILL.md:66-74 SKILL.md:74-80 SKILL.md:80 SKILL.md:81-82 SKILL.md:82 SKILL.md:86-112 SKILL.md:112-118 SKILL.md:118-138 SKILL.md:138-142 SKILL.md:142-150 SKILL.md:150-154 SKILL.md:154-165 SKILL.md:165-171 SKILL.md:171-185 SKILL.md:185-189 SKILL.md:189-201 SKILL.md:201-205 SKILL.md:205-215 SKILL.md:215-221 SKILL.md:221-242 SKILL.md:242-246 SKILL.md:246-254 SKILL.md:254-258 SKILL.md:258-270 SKILL.md:270-274 SKILL.md:274-282 SKILL.md:282-286 SKILL.md:286-292 SKILL.md:292-294 SKILL.md:294-322 SKILL.md:322-332 SKILL.md:332-338 SKILL.md:338-357 SKILL.md:357-361 SKILL.md:361-376 SKILL.md:376-386 SKILL.md:386-394 SKILL.md:394-402 SKILL.md:402-414 SKILL.md:414-420 SKILL.md:420-442 SKILL.md:442-452 SKILL.md:452-460 SKILL.md:460-488 SKILL.md:488-494 SKILL.md:494-496 SKILL.md:496-502 SKILL.md:502-540
📁 Filesystem access (7)
Audited by: codex View Audit History →
Share & cite this report

Share the versioned assessment report, neutral badge, embed card, and citations. Skillstore reports evidence without deciding whether this Skill is safe.

Open versioned report
Security Assessment

Copy report link

https://skillstore.io/skills/emz1998-tdd-vitest-typescript/audits/4?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_report

Markdown badge

[![Skillstore security assessment](https://skillstore.io/badges/skills/emz1998-tdd-vitest-typescript/security.svg)](https://skillstore.io/skills/emz1998-tdd-vitest-typescript?utm_source=security_passport_badge)

HTML badge

<a href="https://skillstore.io/skills/emz1998-tdd-vitest-typescript?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/emz1998-tdd-vitest-typescript/security.svg" alt="Skillstore security assessment" loading="lazy"></a>

Embed card

<iframe src="https://skillstore.io/embed/skills/emz1998-tdd-vitest-typescript.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>
Academic citations (APA · BibTeX · CFF)

APA citation

Emz1998. (2026). tdd-vitest-typescript security audit report (audit version 4) [Author version unspecified]. Skillstore. https://skillstore.io/skills/emz1998-tdd-vitest-typescript/audits/4

BibTeX citation

@techreport{emz1998-emz1998-tdd-vitest-typescript-2026, author = {Emz1998}, title = {tdd-vitest-typescript security audit report (audit version 4)}, institution = {Skillstore}, year = {2026}, number = {4}, url = {https://skillstore.io/skills/emz1998-tdd-vitest-typescript/audits/4}, note = {Author version unspecified} }

CITATION.cff

cff-version: 1.2.0 message: "If you use this Skill, cite its author and this versioned security audit report." title: "tdd-vitest-typescript security audit report (audit version 4)" version: "unspecified" type: report authors: - name: "Emz1998" date-released: "2026-07-05" url: "https://skillstore.io/skills/emz1998-tdd-vitest-typescript/audits/4" identifiers: - type: other value: "skillstore:emz1998-tdd-vitest-typescript:audit:4" description: "Skillstore immutable audit report identifier"

Skillstore Score

Why this score Evidence Confidence: Medium
64
Architecture
85
Maintainability
87
Content
69
Community
78
Spec Compliance

What You Can Build

開始一個經測試的 TypeScript 功能

建立第一個失敗的 Vitest 測試,實作最小可通過的程式碼,並有信心地進行重構。

在程式碼審查中改善測試品質

在合併前識別過於寬泛的斷言、過多 mock、共享狀態和缺少的邊界案例。

學習實用的 TDD 模式

使用 TypeScript 範例練習聚焦測試、非同步斷言、fixture 和覆蓋率習慣。

Try These Prompts

建立第一個失敗測試
使用此技能為這個 TypeScript 行為撰寫第一個失敗的 Vitest 測試。接著說明最小的實作步驟。
覆蓋現有函式
審查這個 TypeScript 函式,並針對正常案例、邊界案例和錯誤提出 Vitest 測試。遵循 Red-Green-Refactor。
以測試安全性進行重構
為這次重構設計 Vitest 安全網。優先採用以行為為核心的測試,並避免與實作細節綁定的斷言。
規劃整合覆蓋範圍
使用 Vitest 為這個 TypeScript 工作流程建立整合測試計畫。區分單元測試、整合測試、mock 和設定需求。

Best Practices

  • 先撰寫失敗測試再實作,並保持每個步驟都小而明確。
  • 測試公開行為、邊界案例和錯誤路徑,而不是私有實作細節。
  • 透過重設 mock 並在每個測試中重新建立可變狀態,讓測試彼此隔離。

Avoid

  • 不要使用一次驗證多個不相關行為的寬泛測試。
  • 不要用 skip 或靜默錯誤處理來隱藏不穩定測試。
  • 不要過度 mock 內部邏輯,導致測試不再證明真實行為。

Frequently Asked Questions

此技能會自動安裝 Vitest 嗎?
它包含設定指引和設定腳本,但使用者應在執行前審查腳本。
它能協助處理現有程式碼嗎?
可以。它能為現有 TypeScript 程式碼加入特徵化測試、邊界案例測試和重構安全測試。
它支援非同步測試嗎?
可以。參考資料包含 promise 斷言、rejected promise、重試和非同步整合範例。
它可以測試 UI 元件嗎?
它提供可支援 UI 測試的 Vitest 模式,但可能仍需要專案專屬的渲染工具。
它只適用於單元測試嗎?
不是。它涵蓋單元測試、整合模式、mock、fixture、snapshot 和覆蓋率習慣。
它會保證完整覆蓋率嗎?
不會。它協助設計有意義的測試,但團隊必須根據產品風險選擇覆蓋目標。

Developer Details

Author

Emz1998

License

MIT

Skillstore revision

r1

Version notice

The author did not declare a version.

Ref

30c73eac2afe762f6aa9c4553158769369d47351

Maintenance freshness

7/21/2026

Usage

7 downloads · 165 views

More from Emz1998

View all
View all