Lost Pixel

Holistic visual testing for your Frontend First class integration with Sto...

README

Lost Pixel

Holistic visual regression testing solution

discord chat twitter profile

Documentation   •   Quickstart   •   Examples

Quick start video



What is Lost Pixel ❓


Lost Pixel is an open source visual regression testing tool. Run visual regression tests on your Storybook and Ladle stories and on your application pages.

ProviderStatusDescription
----------------:----:----------------------------------------------------------------------------------------------------------------------------------------------------------------------
**Storybook**`First
**Ladle**`First
**Pages**Visual
**CustomTake

Lost Pixel consists of two products:

- lost-pixel (_open BETA_) - the core engine driving the visual regression test runs. It could be used standalone and the main use-cases are outlined in the documentation

WhatWhat
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
![ezgif-5-e71eb0773d](https://user-images.githubusercontent.com/29632358/185067771-03467437-badd-466b-ad6c-60d7183d99ae.gif)![ezgif-5-43091ece5d](https://user-images.githubusercontent.com/29632358/185067989-3f2d818b-c01f-4304-97f6-77295b1970d9.gif)

- lost-pixel-platform (_closed BETA_) - the UI and CI helpers that allow you to use lost-pixel's managed version. This includes specified regression UI, collaboration with team members and easy approval/rejection process for the snapshots. Configure it just once and enjoy hassle free visual regression tests integrated into your GitHub actions pipeline.


🚀 Get the platform beta invite 🚀



Quick start ⚡


Storybook 🖼

Assuming you are using [basic example of Storybook](<[https://github.com/tajo/ladle](https://github.com/snipcart/nextjs-storybook-example)>). This setup will run visual regression tests against all the storybook stories on every push.

You can find more examples in the examples repository. You can learn more about Lost Pixel workflow and get more useful recipes in documentation.

Add lostpixel.config.ts at the root of the project:

  1. ```typescript
  2. import { CustomProjectConfig } from 'lost-pixel';

  3. export const config: CustomProjectConfig = {
  4.   storybookShots: {
  5.     storybookUrl: './storybook-static',
  6.   },
  7.   generateOnly: true,
  8.   failOnDifference: true,
  9. };
  10. ```

Add GitHub action .github/workflows/lost-pixel-run.yml

  1. ```yml
  2. on: [push]

  3. jobs:
  4.   build:
  5.     runs-on: ubuntu-latest

  6.     steps:
  7.       - name: Checkout
  8.         uses: actions/checkout@v2

  9.       - name: Setup Node
  10.         uses: actions/setup-node@v2
  11.         with:
  12.           node-version: 16.x
  13.           cache: 'npm'

  14.       - name: Install dependencies
  15.         run: npm ci

  16.       - name: Build Storybook
  17.         run: npm run build-storybook

  18.       - name: Lost Pixel
  19.         uses: lost-pixel/lost-pixel@v2.23.0
  20. ```

Ladle example 🥄

Assuming you are using basic example of Ladle. This setup will run visual regression tests against all the ladle stories on every push.

You can find more examples in the examples repository. You can learn more about Lost Pixel workflow and get more useful recipes in documentation.

Add lostpixel.config.ts at the root of the project:

  1. ```typescript
  2. import { CustomProjectConfig } from 'lost-pixel';

  3. export const config: CustomProjectConfig = {
  4.   ladleShots: {
  5.     //ip should be localhost when running locally & 172.17.0.1 when running in GitHub action
  6.     ladleUrl: 'http://172.17.0.1:61000',
  7.   },
  8.   generateOnly: true,
  9.   failOnDifference: true,
  10. };
  11. ```

Update package.json with following scripts:

  1. ``` json
  2. "scripts": {
  3.     "serve": "npx serve build -p 61000",
  4.     "build": "ladle build"
  5.   },
  6. ```

Add GitHub action .github/workflows/lost-pixel-run.yml

  1. ```yml
  2. on: [push]

  3. jobs:
  4.   build:
  5.     runs-on: ubuntu-latest

  6.     steps:
  7.       - name: Checkout
  8.         uses: actions/checkout@v2

  9.       - name: Setup Node
  10.         uses: actions/setup-node@v2
  11.         with:
  12.           node-version: 16.x
  13.           cache: 'npm'

  14.       - name: Install dependencies
  15.         run: npm install

  16.       - name: Build ladle
  17.         run: npm run build

  18.       - name: Serve ladle
  19.         run: npm run serve &

  20.       - name: Lost Pixel
  21.         uses: lost-pixel/lost-pixel@v2.23.0
  22. ```

Pages example(next.js) ⚛️

Assuming you are using basic example of Next.js. This setup will run visual regression tests againstselected pages on every push.

You can find more examples in the examples repository. You can learn more about Lost Pixel workflow and get more useful recipes in documentation.

Add lostpixel.config.ts at the root of the project:

  1. ```typescript
  2. import { CustomProjectConfig } from 'lost-pixel';

  3. export const config: CustomProjectConfig = {
  4.   pageShots: {
  5.     pages: [{ path: '/app', name: 'app' }],
  6.     // IP should be localhost when running locally & 172.17.0.1 when running in GitHub action
  7.     baseUrl: 'http://172.17.0.1:3000',
  8.   },
  9.   generateOnly: true,
  10.   failOnDifference: true,
  11. };
  12. ```

Add GitHub action .github/workflows/lost-pixel-run.yml

  1. ```yml
  2. on: [push]

  3. jobs:
  4.   build:
  5.     runs-on: ubuntu-latest

  6.     steps:
  7.       - name: Checkout
  8.         uses: actions/checkout@v2

  9.       - name: Setup Node
  10.         uses: actions/setup-node@v2
  11.         with:
  12.           node-version: 16.x
  13.           cache: 'npm'

  14.       - name: Install dependencies
  15.         run: npm ci

  16.       - name: Build Next app
  17.         run: npm run build

  18.       - name: Run Next app
  19.         run: npm run start &

  20.       - name: Lost Pixel
  21.         uses: lost-pixel/lost-pixel@v2.23.0
  22. ```


  

Support 👨🏼‍💻


Ask a question about Lost Pixel


You can ask questions and initiate discussions about Lost Pixel.

❓ [Ask a question](https://github.com/lost-pixel/lost-pixel/discussions/new)

Create a bug report for Lost Pixel


If you see an error message or run into an issue, help us with creating a bug report!

🐛 [Create bug report](https://github.com/lost-pixel/lost-pixel/issues/new?assignees=&labels=kind%2Fbug&template=bug.yml)

Submit a feature request


If Lost Pixel at the moment doesn't support some mode or does not have a feature we would appreciate your thoughts!

🆕 [Submit feature request](https://github.com/lost-pixel/lost-pixel/issues/new?assignees=&labels=kind%2Ffeature&template=feature.yml)
  

Community

Want to chat about visual regression testing with likeminded people? We've started a community! Discuss your pipelines, tools, testing strategy, get faster support!

Join our Discord



Contributing 🏗️


Lost Pixel is open source in it's heart and welcomes any external contribution. You can refer to CONTRIBUTING.md to get going with the project locally in couple of minutes.