CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-percy--cli

Command line interface for Percy visual testing platform that enables developers to capture, upload, and manage visual snapshots for web applications.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

core-operations.mddocs/

Core Operations

Essential Percy workflow commands for starting, stopping, and executing visual tests with any test runner or static content. These commands form the foundation of Percy's visual testing workflow.

Capabilities

Percy Exec

Start Percy, execute a command (typically a test suite), then automatically stop Percy when the command completes. This is the most common Percy workflow.

/**
 * Execute command with Percy visual testing environment
 * Starts Percy server, runs the specified command, then stops Percy
 * 
 * Usage: percy exec -- <command>
 * 
 * Options:
 *   --parallel          Mark as parallel build (sets PERCY_PARALLEL_TOTAL=-1)
 *   --partial           Mark as partial build (sets PERCY_PARTIAL_BUILD=1)
 *   --testing           Internal testing flag (hidden)
 * 
 * Environment variables set:
 *   PERCY_SERVER_ADDRESS    Local Percy server URL
 *   PERCY_BUILD_ID          Current build identifier
 *   PERCY_BUILD_URL         Percy dashboard URL for build
 *   PERCY_LOGLEVEL          Current logging level
 */
percy exec -- <command>

Usage Examples:

# Run tests with Percy
percy exec -- npm test
percy exec -- yarn test
percy exec -- pytest

# Run specific test files
percy exec -- npm test -- --grep "visual tests"
percy exec -- jest tests/visual/

# Run with parallel builds
percy exec --parallel -- npm test

# Run partial build (for CI matrix builds)
percy exec --partial -- npm run test:unit

Percy Start

Start the Percy process in the background as a daemon. Use this for long-running processes or when you need fine-grained control over when Percy starts and stops.

/**
 * Start Percy process in background
 * Initializes Percy server and creates a new build
 * Must be paired with 'percy stop' to finalize the build
 * 
 * Usage: percy start
 * 
 * Returns: Process continues running until 'percy stop' is called
 */
percy start

Usage Examples:

# Start Percy in background
percy start

# Run your tests (Percy server is available at $PERCY_SERVER_ADDRESS)
npm test

# Stop Percy when done
percy stop

Percy Stop

Stop the Percy process and finalize the current build. This uploads any remaining snapshots and marks the build as complete.

/**
 * Stop Percy process and finalize build
 * Uploads pending snapshots and marks build as complete
 * Should be called after 'percy start' and test execution
 * 
 * Usage: percy stop
 * 
 * Returns: Process exits after build finalization
 */
percy stop

Usage Examples:

# Stop Percy and finalize build
percy stop

# Can be used in scripts
percy start
npm test
percy stop

Percy Ping

Check if Percy process is currently running and responsive. Useful for debugging and health checks.

/**
 * Check if Percy process is running
 * Tests connectivity to local Percy server
 * 
 * Usage: percy ping
 * 
 * Exit codes:
 *   0 - Percy is running and responsive
 *   1 - Percy is not running or not responsive
 */
percy ping

Usage Examples:

# Check if Percy is running
percy ping
echo $?  # 0 if running, 1 if not

# Use in conditional scripts
if percy ping; then
  echo "Percy is running"
else
  echo "Percy is not running"
  percy start
fi

Integration Patterns

CI/CD Integration

# Basic CI workflow
percy exec -- npm test

# Parallel CI workflow (run across multiple machines)
percy exec --parallel -- npm test

# Partial builds (for matrix builds)
percy exec --partial -- npm run test:chrome

Development Workflow

# Long development session
percy start

# Run tests multiple times during development
npm test
npm test
npm test

# Stop when done
percy stop

Docker Integration

# In Dockerfile or docker-compose
ENV PERCY_TOKEN=your-token
RUN percy exec -- npm test

Environment Variables

These environment variables are automatically set by Percy commands:

# Set by 'percy exec' and 'percy start'
PERCY_SERVER_ADDRESS           # Local Percy server URL (e.g., http://localhost:5338)
PERCY_BUILD_ID                 # Current build identifier
PERCY_BUILD_URL                # Percy dashboard URL for current build
PERCY_LOGLEVEL                 # Current logging level

# Configuration variables (can be set by user)
PERCY_PARALLEL_TOTAL           # Number of parallel processes (-1 for auto)
PERCY_PARALLEL_NONCE           # Unique identifier for parallel builds
PERCY_PARTIAL_BUILD            # Mark build as partial (1 to enable)

Process Management

Lifecycle

  1. Start Phase: Percy initializes browser, creates build, starts server
  2. Execution Phase: Tests run and capture snapshots via Percy server
  3. Stop Phase: Percy uploads assets, finalizes build, cleans up resources

Error Handling

# Percy exec handles errors gracefully
percy exec -- npm test
# If tests fail, Percy still finalizes the build properly

# Manual error handling with start/stop
percy start
if npm test; then
  echo "Tests passed"
else
  echo "Tests failed"
fi
percy stop  # Always finalize, regardless of test results

Resource Cleanup

Percy automatically cleans up resources including:

  • Browser processes
  • Temporary files
  • Network connections
  • Background processes

If a process is interrupted, Percy attempts graceful cleanup. For stuck processes, you can force cleanup:

# Force cleanup (if percy stop hangs)
pkill -f percy

Install with Tessl CLI

npx tessl i tessl/npm-percy--cli

docs

app-snapshots.md

build-management.md

configuration.md

core-operations.md

image-uploads.md

index.md

programmatic-api.md

static-snapshots.md

tile.json