Generate tests

From leboncoin/spark-web · View interactive version

Generate tests is an AI agent skill from the GitHub repository leboncoin/spark-web. Generate comprehensive unit tests for a Spark UI component using Vitest and React Testing Library. Use when the user wants to add tests, improve test coverage, or test a specific component.

How to use this skill

Skill file

Generate Tests

Create or update unit tests for Spark UI components following the project's testing standards.

When to Use

Instructions

  1. Test File Location: Tests go in ComponentName.test.tsx in the component directory
  1. Testing Library Setup:
  1. Test Structure:

```tsx

import { describe, it, expect } from 'vitest'

import { render, screen } from '@testing-library/react'

import userEvent from '@testing-library/user-event'

import { ComponentName } from './ComponentName'

describe('ComponentName', () => {

it('should render', () => {

render(<ComponentName {...defaultProps} />)

expect(screen.getByRole('...')).toBeInTheDocument()

})

it('should be accessible', () => {

// Accessibility tests

})

})

```

  1. What to Test:
  1. Accessibility Testing:
  1. Run Tests:

Examples

Reference existing test files in packages/components/src/*/ComponentName.test.tsx for patterns.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.