⏯️Lost Pixel Platform

Setting up Lost Pixel Platform - managed version of Lost Pixel

Lost Pixel Platform offers a managed service with a user-friendly interface for a more efficient visual regression testing workflow.

The platform version provides additional features like collaboration tools, automated test runs, and detailed reporting. Upgrading to the Lost Pixel Platform allows you to streamline your visual regression testing process, improve collaboration with your team, and gain access to valuable insights and analytics.

Lost Pixel Platform has first-class integration with GitHub & GitHub Actions but can be set up with any CI provider, given it runs on GitHub

Storybook + Lost Pixel Platform
Ladle + Lost Pixel Platform
Playwright + Lost Pixel Platform

We need to create lost-pixel.config.js|ts file that will run the whole setup. We will use the example of lost-pixel.com as it is set up on our own platform 😊

lost-pixel.config.ts
import { CustomProjectConfig } from 'lost-pixel';

export const config: CustomProjectConfig = {
	pageShots: {
		pages: [
			{ path: '/', name: 'landing' },
			{
				path: '/blog',
				name: 'blog',
			},
		],
		baseUrl: 'http://172.17.0.1:3000',
	},
	lostPixelProjectId: 'we_will_paste_id_here_later',
	apiKey: process.env.LOST_PIXEL_API_KEY,
};

Next up is the GitHub action declaration file that lives in .github/workflows. We are building & serving our Next.js application & run Lost Pixel on it's pages(defined in the above file):

visual-regression.yml
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    name: Lost Pixel

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16.x

      - name: Instal pnpm
        uses: pnpm/action-setup@v2
        with:
          version: 7.17.1

      - name: Install dependencies
        run: pnpm install

      - name: Build next
        run: pnpm run build

      - name: Start next
        run: pnpm run start &

      - name: Lost Pixel
        uses: lost-pixel/lost-pixel@next
        env:
          LOST_PIXEL_API_KEY: ${{ secrets.LOST_PIXEL_API_KEY }}

Set up the Lost Pixel platform

Visit the Lost Pixel installation page and install Lost Pixel App on organisations & repositories you want to have visual tests on

Sign in using GitHub into app.lost-pixel.com, switch to the correct organisation & select which repositories selected in the previous step should be visible on the Lost Pixel Platform:

From the onboarding-screen copy your project id and replace it in the lost-pixel.config.ts created in the first step

lostPixelProjectId: 'clcuk66iz005wp41h3cauveb2',

Copy the Lost Pixel API key, we will need to do the final step to provide it as a GitHub Action secret.

Set Lost Pixel API key on GitHub

Your visual regression testing workflow is done 🎊

All new pushes to your repository are triggering visual tests that you can conveniently manage yourself or collaboratively with your team!

Last updated