Back to articles
Technology Insight

Automating Web Visual Regression Testing: A Guide to Deploying Shotglass on a VPS

June 3, 2026

Introduction to Visual Regression Testing

In the rapid pace of modern web development, continuous deployment has become the gold standard. However, this velocity introduces a significant risk: unintended visual regressions. A minor CSS tweak or a seemingly isolated JavaScript update can inadvertently break layout structures, misalign call-to-action buttons, or render text unreadable across various screen resolutions. Traditional functional testing tools often miss these aesthetic anomalies, making automated visual regression testing a critical safeguard for enterprise digital assets.

This comprehensive guide details how to build and deploy an autonomous website screenshot and visual monitoring tool using Shotglass on a Virtual Private Server (VPS). By establishing this infrastructure, engineering teams can systematically track UI changes, maintain design fidelity, and guarantee a flawless user experience across updates.

Why Shotglass and a Dedicated VPS?

While several proprietary Cloud-based visual testing platforms exist, they often come with restrictive usage caps or steep tier-based pricing models that scale aggressively with the number of captured pages. Shotglass offers an elegant, open-source alternative that provides total data ownership and flexibility.

Deploying Shotglass on your own VPS yields several distinct advantages:

  • Cost Efficiency: Eliminate monthly per-screenshot fees by leveraging flat-rate VPS resources.
  • Data Privacy: Keep sensitive pre-production staging environments and proprietary UI mockups within your private network infrastructure.
  • Unrestricted Scheduling: Execute high-frequency visual audits across thousands of URLs without worrying about usage limits.
  • Custom Integration: Easily hook the system into your existing CI/CD pipelines, Slack webhooks, or internal enterprise monitoring dashboards.

Prerequisites and Environment Setup

Before initiating the installation, ensure your VPS is provisioned with a clean installation of an enterprise-grade Linux distribution (such as Ubuntu 24.04 LTS or Debian 12) and that you possess root or sudo administrative privileges.

1. System Dependencies and Headless Browsers

Because Shotglass relies on headless browser technology to render pages accurately, the server must be equipped with essential rendering libraries and fonts. Run the following commands to update your package repository and install the fundamental dependencies:

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git build-essential libxss1 libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3 libasound2

2. Installing Node.js Runtime

Shotglass operates on top of the Node.js ecosystem. We recommend utilizing the Node Version Manager (NVM) to install the current Long-Term Support (LTS) version, ensuring runtime stability:

curl -o- [https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh](https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh) | bash
source ~/.bashrc
nvm install --lts

Step-by-Step Installation of Shotglass

With the core environment prepared, we can proceed to clone the repository and configure the Shotglass core framework.

Cloning the Repository

Navigate to your preferred deployment directory (e.g., /opt or your user home directory) and clone the source code:

git clone [https://github.com/your-repo/shotglass.git](https://github.com/your-repo/shotglass.git)
cd shotglass
npm install
Note on Chromium: During the installation phase, the underlying automation driver (such as Puppeteer or Playwright) will download a local headless Chromium binary. If your VPS resides behind a strict firewall or within an isolated VPC, ensure outward HTTP/HTTPS traffic is permitted to download these binaries.

Configuring the Automated Screenshot Engine

The core configuration of Shotglass revolves around defining target domains, viewport dimensions, and acceptable variance thresholds. Create a centralized configuration file named shotglass.config.json in the root directory:

{
  "baseUrl": "[https://yourwebsite.com](https://yourwebsite.com)",
  "paths": ["/", "/about", "/pricing", "/checkout"],
  "viewports": [
    { "name": "desktop", "width": 1920, "height": 1080 },
    { "name": "mobile", "width": 375, "height": 812 }
  ],
  "threshold": 0.1,
  "storagePath": "./screenshots"
}

Key Parameter Breakdown:

  • viewports: Allows simultaneous testing of responsive layouts, preventing mobile layout breakage during desktop-focused updates.
  • threshold: Defines the pixel mismatch percentage (0.1 equates to 10%) before the system flags a visual variance as a failure. Adjust this to accommodate dynamic content elements like sliding banners or video embeds.

Executing Visual Regression Analysis

Shotglass operates using a Baseline vs. Current comparison paradigm. The process flows through three distinct phases:

  1. Baseline Capture: Establish a trusted visual state (typically captured from your production environment).
  2. Current Capture: Capture screenshots from the new deployment or staging environment.
  3. Diff Generation: The engine overlays both images, pixel by pixel, highlighting discrepancies in high-contrast magenta or red.

To execute a comparison script via the command line, run:

npm run shotglass:compare

The output will generate a comprehensive HTML report indicating whether the visual delta falls within your acceptable tolerance thresholds.

Automation: Cron Scheduling and CI/CD Pipeline Integration

To transform Shotglass into a proactive monitoring sentinel, you must automate its execution loop. Here are the two most effective methods for production environments:

Method A: Periodic Crontab Execution

If you aim to monitor production websites for unauthorized modifications or unexpected dynamic content breakages, schedule Shotglass to run every hour via the system cron service:

0 * * * * cd /path/to/shotglass && /usr/local/bin/npm run shotglass:compare >> /var/log/shotglass.log 2>&1

Method B: Integrating with Gitlab CI or GitHub Actions

For development teams, the ideal touchpoint is right before code merge. You can configure a runner on your VPS to trigger Shotglass automatically whenever a pull request is created, preventing visual bugs from ever reaching production servers.

Best Practices for Eliminating False Positives

One of the biggest challenges in visual regression automation is managing dynamic content, which frequently triggers false failure alerts. To maintain a high-signal, low-noise monitoring framework, implement these advanced strategies:

  • DOM Element Masking: Configure Shotglass to hide or inject custom CSS to hide dynamic widgets (such as third-party live chats, ad banners, or changing timestamps) prior to capturing the screenshot.
  • Network Idle Waiting: Instruct the browser automation wrapper to delay screenshot capture until the network state has reached full quiescence (networkidle0), guaranteeing that heavy assets, web fonts, and tracking scripts are fully parsed.
  • Deterministic Data Injection: When testing staging environments, hook your tool into a standardized staging database with static, predictable dummy records to prevent data-driven layout shifts.

Conclusion

Building an autonomous visual regression testing tool with Shotglass on a VPS grants engineering teams an elite layer of quality assurance without the prohibitive costs of SaaS models. By systematically capturing layout baselines, executing pixel-differential analysis, and automating execution via cron or CI pipelines, you establish an ironclad defense against UI regressions. Invest the time to fine-tune your element masking and variance thresholds, and you will achieve a reliable, low-maintenance visual sentinel protecting your digital storefront 24/7.

Automating Web Visual Regression Testing: A Guide to Deploying Shotglass on a VPS | DPTCloud