Skip to content

Get Started with Lab Testing โ€‹

Lab Testing Preview

Get up and running with Optima's Lab Testing also in under 5 minutes. This guide will walk you through setting up automated Lighthouse audits for controlled performance analysis.

Prerequisites

Before you begin, make sure you have:

  • A publicly accessible website or staging environment
  • Basic understanding of web performance metrics
  • An Optima account (sign up at optimajs.com)

๐Ÿš€ Step 1: Create Your Account & Project โ€‹

  1. Sign up at optimajs.com
  2. Verify your email address
  3. Create your organization or accept a team invitation
  4. Create your first project for Lab Testing

No SDK Required

Unlike RUM, Lab Testing doesn't require any code changes to your application. We test your site externally using Google's Lighthouse.

๐Ÿงช Step 2: Create Your First Lab Test โ€‹

  1. Go to your project dashboard
  2. Click "Lab Testing" in the sidebar
  3. Click "New Lab Test" or "Create Test"

Configure Your Test โ€‹

Fill out the test configuration form:

javascript
// Example test configuration
{
  "name": "Homepage Performance Test",
  "url": "https://yoursite.com",
  "device": "desktop", // or "mobile"
  "network": "4g", // Options: "4g", "3g", "slow-3g", "cable"
  "schedule": {
    "frequency": "daily", // Options: "hourly", "daily", "weekly"
    "time": "09:00" // UTC time for daily/weekly tests
  },
  "categories": [
    "performance",
    "accessibility", 
    "best-practices",
    "seo"
  ],
  "advanced": {
    "throttling": true,
    "emulatedFormFactor": "desktop",
    "locale": "en-US",
    "customUserAgent": "" // Optional
  }
}

Test Configuration Options โ€‹

Device Types โ€‹

  • Desktop: Standard desktop browser simulation
  • Mobile: Mobile device simulation (Nexus 5X)

Network Conditions โ€‹

  • Cable: High-speed broadband (5 Mbps down, 1 Mbps up)
  • 4G: Mobile 4G (1.6 Mbps down, 750 Kbps up, 150ms RTT)
  • 3G: Mobile 3G (400 Kbps down, 400 Kbps up, 300ms RTT)
  • Slow 3G: Slow mobile connection (400 Kbps down, 400 Kbps up, 2000ms RTT)

Audit Categories โ€‹

  • Performance: Core Web Vitals, load times, optimization opportunities
  • Accessibility: WCAG compliance, screen reader compatibility
  • Best Practices: Security, modern web standards
  • SEO: Search engine optimization factors

โฐ Step 3: Schedule Your Tests โ€‹

Scheduling Options โ€‹

One-time Test โ€‹

Run immediately for quick analysis:

javascript
{
  "schedule": {
    "type": "immediate"
  }
}

Recurring Tests โ€‹

Set up automated testing:

Daily Tests:

javascript
{
  "schedule": {
    "frequency": "daily",
    "time": "09:00", // UTC
    "timezone": "America/New_York" // Optional
  }
}

Weekly Tests:

javascript
{
  "schedule": {
    "frequency": "weekly",
    "day": "monday", // monday, tuesday, etc.
    "time": "09:00"
  }
}

Hourly Tests:

javascript
{
  "schedule": {
    "frequency": "hourly",
    "interval": 6 // Every 6 hours
  }
}

๐Ÿ“Š Step 4: Understanding Your Results โ€‹

Performance Scores โ€‹

Lab tests provide detailed performance metrics:

Core Web Vitals โ€‹

  • Largest Contentful Paint (LCP): Loading performance
  • First Input Delay (FID): Interactivity (simulated)
  • Cumulative Layout Shift (CLS): Visual stability

Additional Metrics โ€‹

  • First Contentful Paint (FCP): Time to first content
  • Speed Index: How quickly content is visually displayed
  • Time to Interactive (TTI): When page becomes fully interactive
  • Total Blocking Time (TBT): Main thread blocking time

Opportunities & Diagnostics โ€‹

Each test provides actionable recommendations:

  • Eliminate render-blocking resources
  • Properly size images
  • Defer offscreen images
  • Minify CSS/JavaScript
  • Use efficient cache policies

๐Ÿ”„ Step 5: Compare and Track Progress โ€‹

Historical Comparisons โ€‹

  • Trend Analysis: Track performance over time
  • Before/After: Compare deployments
  • Regression Detection: Identify performance degradations

Alerts & Notifications โ€‹

Set up alerts for performance thresholds:

javascript
{
  "alerts": {
    "performance": {
      "threshold": 90, // Alert if score drops below 90
      "enabled": true
    },
    "lcp": {
      "threshold": 2.5, // Alert if LCP > 2.5s
      "enabled": true
    }
  },
  "notifications": {
    "email": ["team@yourcompany.com"],
    "slack": {
      "webhook": "your-slack-webhook-url",
      "channel": "#performance"
    }
  }
}

๐Ÿ”ง Advanced Configuration โ€‹

Custom Headers โ€‹

Add authentication or custom headers:

javascript
{
  "advanced": {
    "customHeaders": {
      "Authorization": "Bearer your-token",
      "X-Custom-Header": "value"
    }
  }
}

Multiple URLs โ€‹

Test multiple pages in sequence:

javascript
{
  "urls": [
    "https://yoursite.com/",
    "https://yoursite.com/products",
    "https://yoursite.com/checkout"
  ]
}

Budget Assertions โ€‹

Set performance budgets:

javascript
{
  "budgets": {
    "performance": 90,
    "lcp": 2.5,
    "fcp": 1.8,
    "cls": 0.1
  }
}

๐Ÿš€ CI/CD Integration โ€‹

GitHub Actions โ€‹

Integrate with your deployment pipeline:

yaml
name: Performance Testing
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  performance:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Run Optima Lab Test
        run: |
          curl -X POST "https://api.optimajs.com/v1/lab-tests" \
            -H "Authorization: Bearer ${{ secrets.OPTIMA_API_KEY }}" \
            -H "Content-Type: application/json" \
            -d '{
              "url": "https://your-staging-site.com",
              "device": "desktop",
              "wait": true
            }'

API Integration โ€‹

Use our REST API for custom integrations:

bash
# Create a test
curl -X POST "https://api.optimajs.com/v1/lab-tests" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yoursite.com",
    "device": "mobile",
    "network": "4g"
  }'

# Get test results
curl -X GET "https://api.optimajs.com/v1/lab-tests/{test-id}" \
  -H "Authorization: Bearer YOUR_API_KEY"

๐Ÿ“ˆ Best Practices โ€‹

Test Strategy โ€‹

  1. Baseline Testing: Establish performance baselines
  2. Pre-deployment: Test before going live
  3. Regular Monitoring: Schedule recurring tests
  4. Critical Path: Focus on key user journeys

Optimization Workflow โ€‹

  1. Identify Issues: Use test recommendations
  2. Prioritize Fixes: Focus on high-impact optimizations
  3. Implement Changes: Make performance improvements
  4. Validate: Run new tests to confirm improvements
  5. Monitor: Set up alerts for regression detection

๐Ÿšจ Troubleshooting โ€‹

Common Issues โ€‹

Tests Failing to Run:

  • Verify URL is publicly accessible
  • Check for authentication requirements
  • Ensure site responds within timeout limits

Inconsistent Results:

  • Network conditions affect results
  • Server load can impact performance
  • Consider running multiple tests for averages

Missing Data:

  • Some metrics require specific page conditions
  • JavaScript-heavy sites may need longer timeouts
  • Check for blocking resources or errors

โœ… Next Steps โ€‹

Now that you have Lab Testing set up:

  1. Analyze Results - Review your first test results
  2. Set Up Monitoring - Schedule regular tests
  3. Configure Alerts - Get notified of performance issues
  4. Optimize Performance - Implement recommended improvements
  5. Add RUM - Complement with real user data

Pro Tip

Combine Lab Testing with our Real User Monitoring for complete performance visibility. Lab Testing provides controlled analysis while RUM shows real-world user experience.