npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@testivai/witness-cli

v0.1.21

Published

TestivAI CLI - Universal visual regression testing for any framework

Readme

@testivai/witness-cli

Universal visual regression testing CLI - Record visual tests without writing code, run them anywhere.

Overview

The TestivAI CLI enables visual regression testing for any test framework (Selenium, Cypress, etc.) using the Sidecar Pattern. Instead of building separate SDKs for each framework, this CLI runs alongside your existing tests and uses the testivai.witness() function to capture visual evidence.

Installation

# Install CLI globally
npm install -g @testivai/witness-cli

# Initialize your project (installs all dependencies)
testivai init

Dependencies

The TestivAI CLI requires:

  • @playwright/test ^1.40.0 - Test runner framework
  • playwright ^1.40.0 - Browser automation
  • @testivai/witness-playwright - TestivAI reporter (for batch uploads)

Note: These dependencies are automatically installed when you run testivai init. In CI/CD environments, browsers are not auto-installed - you'll need to run npx playwright install chromium.

Quick Start

# 1. Initialize your project
testivai init

# 2. Authenticate
testivai auth <your-api-key>

# 3. Record a visual test (no code required!)
testivai record https://staging.myapp.com

# 4. Run tests
testivai run

Commands

testivai init

Initialize TestivAI in your project.

testivai init

Options:

  • -f, --force - Overwrite existing configuration

This command will:

  • Install Playwright and TestivAI reporter dependencies
  • Create testivai.config.ts configuration file
  • Create visual-tests/ directory
  • Install Playwright browsers

testivai auth <api-key>

Authenticate with your TestivAI API key.

testivai auth tstvai-abc123xyz

Or use environment variable:

export TESTIVAI_API_KEY=tstvai-abc123xyz
testivai auth

testivai record <url>

Record a visual test by interacting with your app.

# Single page recording
testivai record https://staging.myapp.com/checkout

# Multi-page recording (mark pages during recording)
testivai record https://staging.myapp.com --multi-page

Options:

  • -o, --output <file> - Custom output filename
  • --no-inject - Output raw Playwright code without TestivAI injection
  • --multi-page - Enable multi-page capture mode

Multi-Page Recording

When using --multi-page mode:

  1. A browser opens with your app
  2. Navigate through your application
  3. Press Ctrl+Shift+W to mark a page for capture
  4. Enter a descriptive name (e.g., "login-page", "checkout-form")
  5. Continue navigating and marking pages
  6. Close the browser when finished

The CLI generates a test file with all marked pages:

test.describe('Multi-page visual test', () => {
  test('captures marked pages', async ({ page }) => {
    // Page 1: login-page
    await page.goto('https://staging.myapp.com/login');
    await testivai.witness(page, testInfo, 'login-page');
    await page.waitForTimeout(1000);
    
    // Page 2: dashboard
    await page.goto('https://staging.myapp.com/dashboard');
    await testivai.witness(page, testInfo, 'dashboard');
    await page.waitForTimeout(1000);
    
    // Page 3: checkout-form
    await page.goto('https://staging.myapp.com/checkout');
    await testivai.witness(page, testInfo, 'checkout-form');
    await page.waitForTimeout(1000);
  });
});

testivai run [files]

Execute visual tests and upload results to TestivAI.

# Run all tests
testivai run

# Run specific test
testivai run visual-tests/checkout.spec.ts

# Run with verbose output
testivai run --verbose

# Run in CI/CD (quiet mode)
testivai run --quiet

Options:

  • --verbose - Show detailed Playwright output
  • --quiet - Suppress output (ideal for CI/CD)
  • --update-baselines - Auto-approve all visual diffs as new baselines

Batch Uploads

The CLI automatically uploads all screenshots in a batch to TestivAI:

  • Multiple screenshots from a single test run are grouped together
  • Receives a single Batch ID for the entire test run
  • Results appear together in your TestivAI dashboard

Example output:

🧪 Running 3 visual test(s)...

✅ All visual tests passed (3 passed, 12.3s)
📊 Batch ID: 123e4567-e89b-12d3-a456-426614174000
   View results at: https://dashboard.testiv.ai

Global Options

| Flag | Description | |------|-------------| | -v, --version | Print CLI version | | -h, --help | Show help | | --verbose | Detailed output | | -q, --quiet | Suppress banner (for CI) | | --debug | Debug mode |

Configuration

testivai.config.ts

export default {
  // Base URL (optional)
  baseUrl: 'https://staging.myapp.com',
  
  // Output directory for tests
  outputDir: './visual-tests',
  
  // Viewport settings
  viewport: {
    width: 1280,
    height: 720,
  },
};

Environment Variables

| Variable | Purpose | |----------|---------| | TESTIVAI_API_KEY | API key for authentication | | SKIP_BROWSER_INSTALL | Set to 1 to skip automatic browser installation |

CI/CD Integration

GitHub Actions

- name: Run Visual Tests
  env:
    TESTIVAI_API_KEY: ${{ secrets.TESTIVAI_API_KEY }}
  run: testivai run --quiet

Jenkins

stage('Visual Tests') {
  environment {
    TESTIVAI_API_KEY = credentials('testivai-api-key')
    SKIP_BROWSER_INSTALL = '1'
  }
  steps {
    sh 'npm install @testivai/witness-cli'
    sh 'npx playwright install chromium'
    sh 'testivai run --quiet'
  }
}

Exit Codes

| Code | Meaning | |------|---------| | 0 | Success - all tests passed | | 1 | Test failed - visual diff detected | | 2 | Configuration error | | 3 | Network error | | 4 | Runtime error |

Troubleshooting

"Playwright not found" Error

If you see this error when running testivai run:

❌ Playwright not found!

Solution:

# Option 1: Use the init command (recommended)
testivai init

# Option 2: Manual installation
npm install --save-dev @playwright/test playwright
npx playwright install

"Command not found: testivai"

Solution:

# Install globally
npm install -g @testivai/witness-cli

# Or use npx
npx @testivai/witness-cli run

Browsers not installed in CI

Solution: Add this to your CI script:

npx playwright install chromium --with-deps

API Key Issues

Solution:

# Check if API key is set
echo $TESTIVAI_API_KEY

# Or re-authenticate
testivai auth <your-api-key>

For more help, visit: https://docs.testiv.ai

The Sidecar Pattern

Instead of rewriting your Selenium/Cypress tests, use TestivAI as a "sidecar":

  1. Your Test runs business logic (login, navigate, etc.)
  2. TestivAI captures visual state at the end
  3. Results appear in the TestivAI dashboard

This allows you to add visual regression testing to any framework without changing your existing tests.

License

MIT