The bugster generate command analyzes your codebase and automatically creates comprehensive test specifications. It understands your application structure and generates relevant test cases for your pages and components.

You must run bugster init before using the generate command. The command requires your project to be properly configured and authenticated.

Basic Usage

bugster generate

This command will:

  1. Analyze your codebase structure and components
  2. Generate test specifications for all detected pages
  3. Save test files to .bugster/tests/ directory
  4. Organize tests by feature/page folders

How It Works

1

Codebase Analysis

Bugster scans your Next.js project to understand:

  • Page structure (App Router or Pages Router)
  • Component dependencies and imports
  • Authentication requirements
  • Form elements and user interactions
2

AI Test Generation

Using the codebase analysis, AI creates:

  • Realistic user scenarios and workflows
  • Test steps that match your UI components
  • Expected outcomes for each interaction
  • Context-aware test cases based on page functionality
3

Test Organization

Generated tests are saved as:

  • YAML files with clear, readable test specifications
  • Organized in folders matching your page structure
  • Numbered for execution order (1_login.yaml, 2_signup.yaml)

Command Flags and Options

Specific Page Generation

Generate tests only for the selected pages in your application.

bugster generate --page "pages/auth.tsx","pages/dashboard.tsx"

Test Count Generation

Generate a certain amount of tests.

bugster generate --count 5

Combined Usage Examples

Development Workflow

# Quick generation for specific feature
bugster generate --page "app/auth/page.tsx" --count 3

# Comprehensive testing for critical pages
bugster generate --page "pages/checkout.tsx","pages/payment.tsx" --count 10

Generated Test Structure

After running bugster generate, your project structure will include:

your-project/
├── .bugster/
   ├── config.yaml
   └── tests/
       ├── auth/
          ├── 1_login.yaml
          └── 2_signup.yaml
       ├── dashboard/
          ├── 1_overview.yaml
          └── 2_settings.yaml
       └── checkout/
           ├── 1_cart.yaml
           ├── 2_payment.yaml
           └── 3_confirmation.yaml

Test File Format

Each generated test file contains:

# @META:{"id":"unique-test-id","last_modified":"2024-01-15T10:30:00Z"}
# This comment contains machine-readable metadata that should not be modified

name: "User Login Flow"
page: "Login"
page_path: "/auth/login"
task: "Test user authentication with valid credentials"
steps:
  - "Navigate to login page"
  - "Enter username 'admin@example.com'"
  - "Enter password 'admin123'"
  - "Click login button"
  - "Verify successful login and dashboard redirection"
expected_result: "User successfully logs in and is redirected to dashboard"

Understanding Test Generation

Page Detection

Bugster automatically detects pages based on:

Pages Router

Detection: Files in pages/ directory

Examples:

  • pages/index.tsx/
  • pages/about.tsx/about
  • pages/user/[id].tsx/user/:id

Excludes: API routes, _app.tsx, _document.tsx

App Router

Detection: page.tsx files in app/ directory

Examples:

  • app/page.tsx/
  • app/about/page.tsx/about
  • app/user/[id]/page.tsx/user/:id

Excludes: layout.tsx, loading.tsx, API routes

Test Context Generation

AI considers multiple factors when generating tests:

Generation Status and Progress

During generation, you’ll see progress updates:

🔍 Starting analysis...
 Analysis completed!
🧪 Generating test cases...
   Job submitted (ID: abc123)
 Processing...
   Status: processing Elapsed: 15s
   Status: processing Elapsed: 30s  
   Status: completed Elapsed: 45s
 Test generation complete
📁 Test specs saved to: .bugster/tests

Generation Time

  • Small projects (5-10 pages): 30-60 seconds
  • Medium projects (10-25 pages): 1-3 minutes
  • Large projects (25+ pages): 3-5 minutes

Best Practices

Selective Generation

Use —page flag for specific feature testing

Focus on critical paths when time is limited

Generate incrementally for new features

Combine with existing tests rather than full regeneration

Test Quality

Review generated tests before committing

Customize for your workflows if needed

Ensure credential alignment with your test users

Validate test coverage matches your requirements

Troubleshooting

Next Steps

After generating tests, you can: