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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@powala/react-native-visual-regression

v1.0.2

Published

Visual Regression for React Native using Storybook

Downloads

5

Readme

react-native-visual-regression

This package orchestrates several tools to provide a flexible visual regression solution for React Native (RN).

If you are using Storybook in your project, you can perform visual regression testing against existing stories.

Storybook

You need to have an app build that can launch in Storybook mode. See the example directory for reference.

Storybook allows you to render any screen or component in your application. By capturing screenshots of these screens or components in a controlled environment, you can ensure consistent results.

Rendering only the screens or components that you are interested in regression testing will be more efficient, as you won't need to navigate through multiple screens to reach a particular screen.

Installation

npm install --save-dev @powala/react-native-visual-regression

Add to your .gitignore

visual-regression/current
visual-regression/diff
.maestro/visual_regression.yaml
VisualRegressionTestReport.md

Usage

Add the configuration file rn-vr.config.js to the root of your project:

module.exports = {
  devices: [ // You can run visual regression for multiple devices
    {
      platform: 'android',
      name: 'Pixel_8_API_34',
    },
  ],
  appId: 'com.anonymous.VisualRegression', // appId of the app
  storiesDirectories: [ // Directories where the stories are located
    './example/.storybook'
  ]
};

Mark which story should have visual regression coverage:

export const AnotherExample: StoryObj<typeof MyButton> = {
  args: {
    text: 'Another example',
  },
  parameters: {
    visualRegression: true,
  }
};
Run Visual Regression:
npx rn-vr

A visual regression run will generate a set of assets in the visual-regression directory at the root of the project.

  • baseline: The current source of truth for visual regression. If a given story does not have a baseline set, the initial run will create the baseline screenshot. This should be committed to version control as a reference.

  • current: Screenshots produced by the latest visual regression run. If approved, these will become the baseline and the new source of truth. This should be omitted from version history.

  • diff: A comparison between the current and baseline screenshots. This should be omitted from version history.

Additionally, the run will produce:

  • VisualRegressionTestReport.md: A report summarizing the run.
  • .maestro/visual_regression.yaml: An autogenerated Maestro flow file. You can exclude this from version history if desired.
Approve changes
npx rn-vr -a

Command Arguments

| Argument | Default | Example | Notes | | -------------- | --------- | -------------------------- | ---------------------------------------------------- | | --approve | -a| undefined | -a | Approve base images with the current version | | --file | -f | undefined | -f .storybook/stories/Button/Button.stories.tsx | Filename to run visual regression on | | --story | -s | undefined | -s MyButton-AnotherExample | Target a particular Story kind-name |

Prerequisites

  • Ensure the app you want to run against is installed on the simulator/emulator you want to use.
  • For best results run the app in Release mode, otherwsie bundler will slow down the run and might produce inconsistencies.
  • The app can launch in Storybook mode, preferably without a UI, so you can capture only the screen. See the example directory for more details.
  • Story files should end with *.stories.tsx.