Contents
Scout: When AI Reads Your Code and Writes Tests for You

Scout: When AI Reads Your Code and Writes Tests for You

Imagine having 50 components with forms, buttons and navigation. QA needs scenarios. A developer says, “There are data-testids; just write tests.” The QA engineer sighs and starts examining every component manually.

Scout automates the process: it reads your source code and generates Playwright tests.

The problem: tests from code versus tests from the UI

There are two approaches to generating tests.

Dynamic analysis (runtime)

Run the application → Explore the UI → Extract elements → Generate tests

Advantage: Sees the application's actual state.
Disadvantage: Requires a running application and is slower.

Static analysis (source code)

Read source code → Analyze components → Generate tests

Advantage: Does not need a running application and is faster.
Disadvantage: Cannot see runtime behavior.

Scout uses static analysis: it reads code and generates tests directly from it. This is ideal for CI/CD without a staging server, quick generation during development and analysis before deployment.

What does Scout do?

Scout has three main capabilities:

1. ANALYZE  → Scans the project and extracts forms, buttons and links
2. MARK     → Calls Marker to add data-testid
3. GENERATE → LLM generates test scenarios

Output:

  • JSON scenarios compatible with Sentinel
  • Python tests using Playwright and Pytest

Example workflow

bash
# 1. Analyze the project
python main.py analyze /path/to/frontend

# Output:
# Found 47 components
# - 12 forms with 38 input fields
# - 45 buttons (23 with click handlers)
# - 67 data-testid attributes
# - 15 navigation links

# 2. Generate scenarios
python main.py generate /path/to/frontend

# Output:
# Generated 156 test scenarios
# - 47 happy path scenarios
# - 62 validation scenarios
# - 31 navigation scenarios
# - 16 edge case scenarios

How does Scout analyze code?

Scout uses regex patterns to detect elements in different frameworks.

Angular detection

html
<!-- Scout recognizes -->
<form [formGroup]="contactForm" (ngSubmit)="onSubmit()">
  <input formControlName="email" [required]="true">
  <button type="submit" data-testid="btn-submit">Send</button>
</form>

<a routerLink="/about">About</a>

Extracted information:

  • A form with formGroup “contactForm”
  • An input with formControlName “email” and required validation
  • A button with data-testid “btn-submit”
  • A RouterLink to “/about”

React/JSX detection

jsx
// Scout recognizes
<form onSubmit={handleSubmit}>
  <input 
    type="email" 
    required 
    data-testid="input-email"
    onChange={(e) => setEmail(e.target.value)}
  />
  <button type="submit">Submit</button>
</form>

<Link to="/dashboard">Dashboard</Link>

Vue detection

vue
<!-- Scout recognizes -->
<template>
  <form @submit.prevent="submitForm">
    <input v-model="email" required data-testid="input-email">
    <button type="submit">Submit</button>
  </form>
  
  <router-link :to="{ name: 'home' }">Home</router-link>
</template>

Intelligent URL inference

Scout infers the page URL from the file path:

python
# Angular pattern
src/app/pages/contact/contact.component.html
→ URL: /contact

# Vue/Nuxt pattern
pages/about/index.vue
→ URL: /about

# React pattern
src/pages/Dashboard.tsx
→ URL: /dashboard

This allows it to generate tests with the correct page.goto() calls.

What does Scout generate?

1. Sentinel JSON format

json
{
  "id": "contact-ecbaee-successful-form-submission-00",
  "name": "Successful form submission with valid data",
  "description": "Tests that the contact form can be submitted successfully",
  "page_url": "/contact",
  "steps": [
    {
      "action": "fill",
      "selector": "[data-testid=\"input-name\"]",
      "value": "John Doe",
      "description": "Fill name field"
    },
    {
      "action": "fill",
      "selector": "[data-testid=\"input-email\"]",
      "value": "john.doe@example.com",
      "description": "Fill email field with valid format"
    },
    {
      "action": "click",
      "selector": "[data-testid=\"btn-submit\"]",
      "value": "",
      "description": "Click submit button"
    },
    {
      "action": "verify_visible",
      "selector": ".success-message",
      "value": "",
      "description": "Verify success message appears"
    }
  ]
}

2. Playwright Python tests

python
import pytest
from playwright.sync_api import Page

def test_successful_form_submission_with_valid_data(page: Page, base_url: str):
    """Tests that the contact form can be submitted successfully"""
    page.goto(f"{base_url}/contact")
    
    # Fill name field
    page.locator("[data-testid=\"input-name\"]").fill("John Doe")
    
    # Fill email field with valid format
    page.locator("[data-testid=\"input-email\"]").fill("john.doe@example.com")
    
    # Click submit button
    page.locator("[data-testid=\"btn-submit\"]").click()
    
    # Verify success message appears
    expect(page.locator(".success-message")).to_be_visible()


def test_form_validation_required_fields(page: Page, base_url: str):
    """Tests that required field validation works correctly"""
    page.goto(f"{base_url}/contact")
    
    # Try to submit empty form
    page.locator("[data-testid=\"btn-submit\"]").click()
    
    # Verify validation errors appear
    expect(page.locator(".error-message")).to_be_visible()

Tests can run immediately with pytest.

Types of generated scenarios

Scout generates four categories:

1. Happy path

python
def test_successful_login():
    # Fill valid data → expect success

2. Validation tests

python
def test_email_format_validation():
    # Fill an invalid email → expect an error

def test_required_field_validation():
    # Leave a required field empty → expect an error

3. Navigation tests

python
def test_navigation_to_about_page():
    # Click the link → verify the correct page

4. Edge cases

python
def test_form_with_special_characters():
    # Enter special characters → verify behavior

Scout understands validation

Scout detects validation rules in your code:

typescript
// Angular Reactive Forms
this.form = this.fb.group({
  email: ['', [Validators.required, Validators.email]],
  phone: ['', [Validators.pattern(/^\d{10}$/)]],
  age: ['', [Validators.min(18), Validators.max(100)]]
});

Scout generates tests for:

  • ✅ Required fields
  • ✅ Email format
  • ✅ Pattern matching
  • ✅ Minimum/maximum values
html
<!-- HTML5 validation -->
<input type="email" required minlength="5" maxlength="100">

Scout also recognizes HTML5 attributes and generates appropriate tests.

Scout architecture

┌─────────────────────────────────────────────────────┐
│                  User Interface                      │
│        CLI │ gRPC Server │ MCP Server               │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│                  CodeAnalyzer                        │
│   - Scans .html, .jsx, .tsx, .vue                 │
│   - Regex extraction of forms, buttons and links   │
│   - Validation rule detection                  │
│   - URL inference from file path                    │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│               ScenarioGenerator                      │
│   - Ollama + Qwen3-Coder LLM                        │
│   - Prompt building from analysis                       │
│   - JSON parsing with error recovery                   │
│   - Generation of unique IDs                       │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌──────────────────┬──────────────────────────────────┐
│  Sentinel JSON   │      Playwright Tests            │
│  (scenarios)       │      (pytest)                    │
└──────────────────┴──────────────────────────────────┘

Integration with Marker

Scout can call the Marker service to add data-testid:

bash
# Start the Marker gRPC server
cd ../marker && python grpc_server.py

# Scout adds test IDs and generates scenarios
python main.py full /path/to/frontend

Workflow:

1. Scout analyzes components
2. Scout calls Marker → adds data-testid
3. Scout analyzes again (now with test IDs)
4. Scout generates scenarios

Three ways to use it

1. CLI

bash
# Analysis only
python main.py analyze /path/to/frontend

# Scenario generation only
python main.py generate /path/to/frontend --output ./tests

# Complete workflow
python main.py full /path/to/frontend

# With a custom user for multi-role testing
python main.py generate /path --user admin --role administrator

2. gRPC server

bash
# Start the server
python main.py grpc-server --port 50052

# Call from any language
# Service: ScoutService
# Methods: Analyze, Generate, FullWorkflow

3. MCP server (Claude integration)

json
// claude_desktop_config.json
{
  "mcpServers": {
    "scout": {
      "command": "python",
      "args": ["main.py", "mcp-server"]
    }
  }
}

In Claude:

"Analyze my Angular project and generate tests for the contact form"
→ Claude calls scout_analyze + scout_generate

Scout vs Sentinel: when to use each

AspectScoutSentinel
ApproachStatic code analysisDynamic UI analysis
RequiresSource codeA running application
SpeedFasterSlower; navigates the UI
CoverageEverything in codeOnly what it sees in the UI
ValidationUnderstands validatorsTests real behavior
Ideal forCI/CD and developmentQA and acceptance testing

The best approach: use both!

bash
# 1. Scout for development (fast, from code)
scout generate ./frontend

# 2. Sentinel for QA (precise, from the UI)
sentinel analyze https://staging.app.com

Complete QA toolchain

Marker + Scout + Sentinel make a complete stack:

┌─────────────────────────────────────────────────────┐
│                     MARKER                           │
│   Adds data-testid to components                  │
│   (Automatic element labeling)                 │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│                     SCOUT                            │
│   Analyzes code → generates scenarios                  │
│   (Static analysis + LLM)                          │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│                    SENTINEL                          │
│   Explores running app → validates scenarios           │
│   (Dynamic analysis + LLM)                         │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│              PLAYWRIGHT / PYTEST                     │
│   Runs automated tests                       │
└─────────────────────────────────────────────────────┘

Practical workflow:

bash
# 1. Marker: Add data-testid
python marker/main.py add --project ./frontend

# 2. Scout: Generate tests from code
python scout/main.py generate ./frontend --output ./tests

# 3. (Optional) Sentinel: validate on staging
python sentinel/main.py --url https://staging.app.com

# 4. Run tests
pytest ./tests --base-url https://staging.app.com

Practical example: contact form

Input (Angular component)

html
<!-- contact.component.html -->
<form [formGroup]="contactForm" (ngSubmit)="onSubmit()">
  <div class="form-group">
    <label for="name">Name</label>
    <input 
      id="name"
      formControlName="name"
      data-testid="input-contact-name"
      required>
  </div>
  
  <div class="form-group">
    <label for="email">Email</label>
    <input 
      id="email"
      type="email"
      formControlName="email"
      data-testid="input-contact-email"
      required>
  </div>
  
  <div class="form-group">
    <label for="message">Message</label>
    <textarea
      id="message"
      formControlName="message"
      data-testid="textarea-contact-message"
      minlength="10">
    </textarea>
  </div>
  
  <button type="submit" data-testid="btn-contact-submit">
    Send Message
  </button>
</form>

Output (Playwright tests)

python
# test_contact.py - generated by Scout

def test_successful_contact_form_submission(page: Page, base_url: str):
    """Test successful form submission with valid data"""
    page.goto(f"{base_url}/contact")
    
    page.locator("[data-testid=\"input-contact-name\"]").fill("John Doe")
    page.locator("[data-testid=\"input-contact-email\"]").fill("john@example.com")
    page.locator("[data-testid=\"textarea-contact-message\"]").fill("Hello, this is a test message.")
    page.locator("[data-testid=\"btn-contact-submit\"]").click()


def test_contact_form_required_name(page: Page, base_url: str):
    """Test that name field is required"""
    page.goto(f"{base_url}/contact")
    
    # Leave name empty, fill other fields
    page.locator("[data-testid=\"input-contact-email\"]").fill("john@example.com")
    page.locator("[data-testid=\"textarea-contact-message\"]").fill("Test message here.")
    page.locator("[data-testid=\"btn-contact-submit\"]").click()
    
    # Verify form was not submitted
    expect(page.locator("[data-testid=\"input-contact-name\"]")).to_have_attribute("aria-invalid", "true")


def test_contact_form_email_validation(page: Page, base_url: str):
    """Test that email format is validated"""
    page.goto(f"{base_url}/contact")
    
    page.locator("[data-testid=\"input-contact-name\"]").fill("John")
    page.locator("[data-testid=\"input-contact-email\"]").fill("invalid-email")
    page.locator("[data-testid=\"btn-contact-submit\"]").click()
    
    # Verify email validation error


def test_contact_form_message_minlength(page: Page, base_url: str):
    """Test that message has minimum length requirement"""
    page.goto(f"{base_url}/contact")
    
    page.locator("[data-testid=\"input-contact-name\"]").fill("John")
    page.locator("[data-testid=\"input-contact-email\"]").fill("john@example.com")
    page.locator("[data-testid=\"textarea-contact-message\"]").fill("Short")  # < 10 chars
    page.locator("[data-testid=\"btn-contact-submit\"]").click()
    
    # Verify minlength validation

Four tests from one form, without manual work.

Quick start

bash
# 1. Install Ollama and the model
ollama pull qwen3-coder:30b

# 2. Configure .env
cat > .env << EOF
PROJECT_PATH=/path/to/frontend
OLLAMA_HOST=http://localhost:11434
LLM_MODEL=qwen3-coder:30b
OUTPUT_DIR=./result
EOF

# 3. Analyze the project
python main.py analyze /path/to/frontend

# 4. Generate tests
python main.py generate /path/to/frontend

# 5. Run tests
pytest result/tests/ --base-url http://localhost:4200

Conclusion

Scout changes the way we create tests:

Manual approachWith Scout
Read code and write testsScout reads code for me
Forget edge casesLLM generates validation tests
Inconsistent coverageSystematic analysis of every component
Hours of workMinutes

When to use Scout:

  • ✅ You need tests from existing code
  • ✅ A CI/CD pipeline has no staging server
  • ✅ You need fast generation during development
  • ✅ Analyze coverage before deployment

Scout is your AI QA engineer: it reads code, understands it and writes tests; you review the result.


Scout is part of a QA automation toolchain with Marker and Sentinel. All use local LLMs through Ollama.

All articles