test-writer▌
leonardomso/33-js-concepts · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
Use this skill to generate comprehensive Vitest tests for all code examples in a concept documentation page. Tests verify that code examples in the documentation are accurate and work as described.
Skill: Test Writer for Concept Pages
Use this skill to generate comprehensive Vitest tests for all code examples in a concept documentation page. Tests verify that code examples in the documentation are accurate and work as described.
When to Use
- After writing a new concept page
- When adding new code examples to existing pages
- When updating existing code examples
- To verify documentation accuracy through automated tests
- Before publishing to ensure all examples work correctly
Test Writing Methodology
Follow these four phases to create comprehensive tests for a concept page.
Phase 1: Code Example Extraction
Scan the concept page for all code examples and categorize them:
| Category | Characteristics | Action |
|---|---|---|
| Testable | Has console.log with output comments, returns values |
Write tests |
| DOM-specific | Uses document, window, DOM APIs, event handlers |
Write DOM tests (separate file) |
| Error examples | Intentionally throws errors, demonstrates failures | Write tests with toThrow |
| Conceptual | ASCII diagrams, pseudo-code, incomplete snippets | Skip (document why) |
| Browser-only | Uses browser APIs not available in jsdom | Skip or mock |
Phase 2: Determine Test File Structure
tests/
├── fundamentals/ # Concepts 1-6
├── functions-execution/ # Concepts 7-8
├── web-platform/ # Concepts 9-10
├── object-oriented/ # Concepts 11-15
├── functional-programming/ # Concepts 16-19
├── async-javascript/ # Concepts 20-22
├── advanced-topics/ # Concepts 23-31
└── beyond/ # Extended concepts
└── {subcategory}/
File naming:
- Standard tests:
{concept-name}.test.js - DOM tests:
{concept-name}.dom.test.js
Phase 3: Convert Examples to Tests
For each testable code example:
- Identify the expected output (from
console.logcomments or documented behavior) - Convert to
expectassertions - Add source line reference in comments
- Group related tests in
describeblocks matching documentation sections
Phase 4: Handle Special Cases
| Case | Solution |
|---|---|
| Browser-only APIs | Use jsdom environment or skip with note |
| Timing-dependent code | Use vi.useFakeTimers() or test the logic, not timing |
| Side effects | Capture output or test mutations |
| Intentional errors | Use expect(() => {...}).toThrow() |
| Async code | Use async/await with proper assertions |
Project Test Conventions
Import Pattern
import { describe, it, expect } from 'vitest'
For DOM tests or tests needing mocks:
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
DOM Test File Header
/**
* @vitest-environment jsdom
*/
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
Describe Block Organization
Match the structure of the documentation:
describe('Concept Name', () => {
describe('Section from Documentation', () => {
describe('Subsection if needed', () => {
it('should [specific behavior]', () => {
// Test
})
})
})
})
Test Naming Convention
- Start with "should"
- Be descriptive and specific
- Match the documented behavior
// Good
it('should return "object" for typeof null', () => {})
it('should throw TypeError when accessing property of undefined', () => {})
it('should resolve promises in order they were created', () => {})
// Bad
it('test typeof', () => {})
it('works correctly', () => {})
it('null test', () => {})
Source Line References
Always reference the documentation source:
// ============================================================
// SECTION NAME FROM DOCUMENTATION
// From {concept}.mdx lines XX-YY
// ============================================================
describe('Section Name', () => {
// From lines 45-52: Basic typeof examples
it('should return correct type strings', () => {
// Test
})
})
Test Patterns Reference
Pattern 1: Basic Value Assertion
Documentation:
console.log(typeof "hello") // "string"
console.log(typeof 42) // "number"
Test:
// From lines XX-YY: typeof examples
it('should return correct type for primitives', () => {
expect(typeof "hello").toBe("string")
expect(typeof 42).toBe("number")
})
Pattern 2: Multiple Related Assertions
Documentation:
let a = "hello"
let b = "hello"
console.log(a === b) // true
let obj1 = { x: 1 }
let obj2 = { x: 1 }
console.log(obj1 === obj2) // false
Test:
// From lines XX-YY: Primitive vs object comparison
it('should compare primitives by value', () => {
let a = "hello"
let b = "hello"
expect(a === b).toBe(true)
})
it('should compare objects by reference', () => {
let obj1 = { x: 1 }
let obj2 = { x: 1 }
expect(obj1 === obj2).toBe(false)
})
Pattern 3: Function Return Values
Documentation:
function greet(name) {
return "Hello, " + name + "!"
}
console.log(greet("Alice")) // "Hello, Alice!"
Test:
// From lines XX-YY: greet function example
it('should return greeting with name', () => {
function greet(name) {
return "Hello, " + name + "!"
}
expect(greet("Alice")).toBe("Hello, Alice!")
})
Pattern
How to use test-writer on Cursor
AI-first code editor with Composer
Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add test-writer
Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
The skills CLI fetches test-writer from GitHub repository leonardomso/33-js-concepts and configures it for Cursor.
Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
Verify installation
Confirm successful installation by checking the skill directory location:
Reload or restart Cursor to activate test-writer. Access the skill through slash commands (e.g., /test-writer) or your agent's skill management interface.
Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
List & Monetize Your Skill
Submit your Claude Code skill and start earning
Use Cases▌
Task Automation & Efficiency
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Knowledge Enhancement
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Quality Improvement
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Installation Steps
- 1.Install skill using provided installation command
- 2.Test with simple use case relevant to your work
- 3.Evaluate output quality and relevance
- 4.Iterate on prompts to improve results
- 5.Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices▌
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This▌
✓ Use When
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid When
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path▌
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.7★★★★★38 reviews- ★★★★★Benjamin Haddad· Dec 28, 2024
test-writer is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Kabir Mensah· Dec 24, 2024
Useful defaults in test-writer — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Noor Verma· Dec 20, 2024
Registry listing for test-writer matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Pratham Ware· Dec 12, 2024
test-writer reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Harper Ghosh· Nov 19, 2024
test-writer fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Amelia Lopez· Nov 15, 2024
test-writer has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Kabir Torres· Oct 10, 2024
We added test-writer from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Noor Martin· Oct 6, 2024
Solid pick for teams standardizing on skills: test-writer is focused, and the summary matches what you get after install.
- ★★★★★Kiara Iyer· Sep 25, 2024
We added test-writer from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Diya Torres· Sep 21, 2024
Registry listing for test-writer matched our evaluation — installs cleanly and behaves as described in the markdown.
showing 1-10 of 38