包详细信息

@chromaui/addon-visual-tests

chromaui20.1kMIT不推荐使用1.0.0

This package has been renamed @chromatic-com/storybook

Visual Testing addon with Chromatic

tests, visual tests, vrt, chromatic

自述文件

Storybook Visual Testing addon

The Visual Testing addon enables you to run visual tests on your stories and compare changes with the latest baselines across multiple viewports and browsers to catch UI regressions early in development without leaving Storybook.

Prerequisites

Getting Started

Run the following command to install the addon and automatically configure it for your project via Storybook's CLI:

npx storybook@latest add @chromaui/addon-visual-tests

Start Storybook and navigate to the Visual Tests panel to run your first visual test with Chromatic!

Configuration

By default, the addon offers zero-config support to run visual tests with Storybook and Chromatic. However, you can extend your Storybook configuration file (i.e., .storybook/main.js|ts) and provide additional options to control how tests are run. Listed below are the available options and examples of how to use them.

Option Description
buildScriptName Optional. Defines the custom Storybook build script
options: { buildScriptName: 'deploy-storybook' }
debug Optional. Output verbose debugging information to the console.
options: { debug: true }
projectId Automatically configured. Sets the value for the project identifier
options: { projectId: Project:64cbcde96f99841e8b007d75 }
zip Recommended for large projects. Configures the addon to deploy your Storybook to Chromatic as a zip file.
options: { zip: true }
// .storybook/main.ts

// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
import type { StorybookConfig } from "@storybook/your-framework";

const config: StorybookConfig = {
  framework: "@storybook/your-framework",
  stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
  addons: [
    // Other Storybook addons
    "@chromaui/addon-visual-tests",
    {
      name: "@chromaui/addon-visual-tests",
      options: {
        projectId: "Project:64cbcde96f99841e8b007d75",
        buildScriptName: "build-storybook",
        zip: true,
        debug: true,
      },
    },
  ],
};

export default config;

Updating the GraphQL schema

The addon uses the Chromatic public GraphQL API. We rely on its schema to generate type definitions. The schema needs to be manually updated whenever it changes. To update, take https://github.com/chromaui/chromatic/blob/main/lib/schema/public-schema.graphql and save it under src/gql/public-schema.graphql.

Troubleshooting

Running Storybook with the addon enabled throws an error

When installed, running Storybook may lead to the following error:

const stringWidth = require('string-width');

Error [ERR_REQUIRE_ESM]: require() of ES Module /my-project/node_modules/string-width/index.js is not supported.

This is a known issue when using an older version of the Yarn package manager (e.g., version 1.x). To solve this issue, you can upgrade to the latest stable version. However, if you cannot upgrade, adjust your package.json file and provide a resolution field to enable the Yarn package manager to install the correct dependencies. In doing so, you may be required to delete your node_modules directory and yarn.lock file before installing the dependencies again.

 "resolutions": {
    "jackspeak": "2.1.1"
  }

Alternatively, you could use a different package manager (npm, pnpm).

Contributing

We welcome contributions to the Storybook Addon Visual Tests! If you're a maintainer, refer to the following instructions to set up your development environment with Chromatic.

License

MIT

更新日志

v1.0.0 (Wed Jan 31 2024)

💥 Breaking Change

🐛 Bug Fix

Authors: 4


v0.0.124 (Mon Dec 11 2023)

🐛 Bug Fix

Authors: 1


v0.0.123 (Mon Dec 11 2023)

⚠️ Pushed to main

Authors: 1


v0.0.122 (Thu Nov 30 2023)

🐛 Bug Fix

Authors: 1


v0.0.121 (Thu Nov 30 2023)

🐛 Bug Fix

Authors: 1


v0.0.120 (Wed Nov 22 2023)

🐛 Bug Fix

Authors: 1


v0.0.119 (Fri Nov 17 2023)

🐛 Bug Fix

  • Authenticate with Chromatic CLI using OAuth token rather than projectToken #145 (@ghengeveld)

Authors: 1


v0.0.118 (Fri Nov 17 2023)

🐛 Bug Fix

  • TestBuild: Add SB_TESTBUILD env-variable to switch on --test buildMode in storybook #147 (@ndelangen)

Authors: 1


v0.0.117 (Fri Nov 17 2023)

🐛 Bug Fix

Authors: 2


v0.0.116 (Mon Nov 13 2023)

🐛 Bug Fix

  • Refactor state management to useContext and useReducer #138 (@ghengeveld)

Authors: 1


v0.0.115 (Thu Nov 09 2023)

🐛 Bug Fix

Authors: 1


v0.0.114 (Wed Nov 08 2023)

🐛 Bug Fix

  • Filter lastBuildOnBranch by repositoryOwnerName rather than slug #142 (@ghengeveld)

Authors: 1


v0.0.113 (Fri Nov 03 2023)

🐛 Bug Fix

Authors: 1


v0.0.112 (Thu Nov 02 2023)

🐛 Bug Fix

Authors: 1


v0.0.111 (Mon Oct 30 2023)

🐛 Bug Fix

  • Fix package configuration to be in line with tsup configuration #137 (@ghengeveld)

Authors: 1


v0.0.110 (Mon Oct 30 2023)

🐛 Bug Fix

Authors: 1


v0.0.109 (Mon Oct 23 2023)

🐛 Bug Fix

Authors: 2


v0.0.108 (Fri Oct 20 2023)

🐛 Bug Fix

Authors: 2


v0.0.107 (Fri Oct 13 2023)

🐛 Bug Fix

  • Handle unexpected errors from the runChromaticBuild method (cli misconfigured, missing build commmand, etc) #132 (@weeksling)

Authors: 1


v0.0.106 (Fri Oct 13 2023)

🐛 Bug Fix

  • Refactor Visual Tests stories to more closely control selected story #124 (@tmeasday)

Authors: 1


v0.0.105 (Tue Oct 10 2023)

🐛 Bug Fix

Authors: 2


v0.0.104 (Tue Oct 10 2023)

🐛 Bug Fix

Authors: 2


v0.0.103 (Sun Oct 08 2023)

🐛 Bug Fix

Authors: 2


v0.0.102 (Thu Oct 05 2023)

🐛 Bug Fix

  • Refactor uses of useDialog to pass memoized callbacks #125 (@tmeasday)

Authors: 1


v0.0.101 (Thu Oct 05 2023)

🐛 Bug Fix

Authors: 1


v0.0.100 (Wed Oct 04 2023)

🐛 Bug Fix

  • git is required for visual test addon via chromatic cli #126 (@weeksling)

Authors: 1


v0.0.99 (Wed Oct 04 2023)

🐛 Bug Fix

Authors: 2


v0.0.98 (Wed Sep 27 2023)

🐛 Bug Fix

Authors: 1


v0.0.97 (Wed Sep 27 2023)

🐛 Bug Fix

Authors: 1


v0.0.96 (Tue Sep 26 2023)

🐛 Bug Fix

Authors: 1


v0.0.95 (Sat Sep 23 2023)

🐛 Bug Fix

Authors: 2


v0.0.94 (Fri Sep 22 2023)

🐛 Bug Fix

Authors: 1


v0.0.93 (Fri Sep 22 2023)

🐛 Bug Fix

  • Clear the filter when removing the sidebar toggle button #120 (@tmeasday)

Authors: 1


v0.0.92 (Thu Sep 21 2023)

🐛 Bug Fix

  • Bug: Remove the duplicated manager entry for storybook #119 (@ndelangen)

Authors: 1


v0.0.91 (Thu Sep 21 2023)

🐛 Bug Fix

Authors: 1


v0.0.90 (Thu Sep 21 2023)

🐛 Bug Fix

Authors: 1


v0.0.89 (Wed Sep 20 2023)

🐛 Bug Fix

Authors: 1


v0.0.88 (Wed Sep 20 2023)

🐛 Bug Fix

Authors: 1


v0.0.87 (Wed Sep 20 2023)

🐛 Bug Fix

Authors: 2


v0.0.86 (Wed Sep 20 2023)

🐛 Bug Fix

Authors: 1


v0.0.85 (Wed Sep 20 2023)

🐛 Bug Fix

Authors: 1


v0.0.84 (Tue Sep 19 2023)

🐛 Bug Fix

  • Open dialog to allow creating a new project #91 (@tmeasday)

Authors: 1


v0.0.83 (Tue Sep 19 2023)

🐛 Bug Fix

Authors: 1


v0.0.82 (Tue Sep 19 2023)

🐛 Bug Fix

  • Filter out the local build and selected builds if they are from a previous branch #111 (@tmeasday)

Authors: 1


v0.0.81 (Tue Sep 19 2023)

🐛 Bug Fix

Authors: 1


v0.0.80 (Mon Sep 18 2023)

🐛 Bug Fix

Authors: 1


v0.0.79 (Mon Sep 18 2023)

🐛 Bug Fix

Authors: 1


v0.0.78 (Mon Sep 18 2023)

🐛 Bug Fix

Authors: 1


v0.0.77 (Sat Sep 16 2023)

🐛 Bug Fix

Authors: 1


v0.0.76 (Sat Sep 16 2023)

🐛 Bug Fix

Authors: 1


v0.0.75 (Fri Sep 15 2023)

🐛 Bug Fix

Authors: 2


v0.0.74 (Fri Sep 15 2023)

🐛 Bug Fix

  • Keep the "create first build" UI right up until the running build has captured this story #89 (@tmeasday)

Authors: 1


v0.0.73 (Thu Sep 14 2023)

🐛 Bug Fix

  • Show eyebrow and lock review button when user has no REVIEWER permission #97 (@ghengeveld)

Authors: 1


v0.0.72 (Thu Sep 14 2023)

🐛 Bug Fix

Authors: 1


v0.0.71 (Thu Sep 14 2023)

🐛 Bug Fix

Authors: 1


v0.0.70 (Thu Sep 14 2023)

🐛 Bug Fix

  • Use chromatic.config.json rather than setting options in main.js #94 (@tmeasday)

Authors: 1


v0.0.69 (Thu Sep 14 2023)

🐛 Bug Fix

Authors: 1


v0.0.68 (Thu Sep 14 2023)

🐛 Bug Fix

Authors: 2


v0.0.67 (Tue Sep 12 2023)

🐛 Bug Fix

Authors: 2


v0.0.66 (Tue Sep 12 2023)

🐛 Bug Fix

Authors: 1


v0.0.65 (Mon Sep 11 2023)

🐛 Bug Fix

  • Show a notification when there is trouble accepting #84 (@tmeasday)

Authors: 1


v0.0.64 (Fri Sep 08 2023)

🐛 Bug Fix

Authors: 3


v0.0.63 (Thu Sep 07 2023)

🐛 Bug Fix

  • Reviewing: Rerun query when accepting & un-accepting changes #86 (@ndelangen)

Authors: 1


v0.0.62 (Thu Sep 07 2023)

🐛 Bug Fix

Authors: 1


v0.0.61 (Thu Sep 07 2023)

🐛 Bug Fix

  • Avoid @storybook/design-system in favor of @storybook/components #81 (@ghengeveld)

Authors: 1


v0.0.60 (Thu Sep 07 2023)

🐛 Bug Fix

Authors: 2


v0.0.59 (Thu Sep 07 2023)

🐛 Bug Fix

Authors: 1


v0.0.58 (Wed Sep 06 2023)

🐛 Bug Fix

Authors: 1


v0.0.57 (Wed Sep 06 2023)

🐛 Bug Fix

Authors: 1


v0.0.56 (Wed Sep 06 2023)

🐛 Bug Fix

Authors: 2


v0.0.55 (Tue Sep 05 2023)

🐛 Bug Fix

  • Don't show menu when there's only one viewport or browser #72 (@ghengeveld)

Authors: 1


v0.0.54 (Tue Sep 05 2023)

🐛 Bug Fix

Authors: 1


v0.0.53 (Mon Sep 04 2023)

🐛 Bug Fix

Authors: 1


v0.0.52 (Mon Sep 04 2023)

🐛 Bug Fix

  • Fix status title and viewport/browser selector for accepted stories #70 (@ghengeveld)

Authors: 1


v0.0.51 (Mon Sep 04 2023)

🐛 Bug Fix

  • Separate running/latest build from viewed stories #69 (@tmeasday)
  • Merge branch 'tom/ap-3560-build-ui-for-build-status' into tom/ap-3544-implement-build-of-out-date-behaviour #68 (@tmeasday)

Authors: 1


v0.0.50 (Fri Sep 01 2023)

🐛 Bug Fix

📝 Documentation

Authors: 3


v0.0.49 (Wed Aug 30 2023)

🐛 Bug Fix

Authors: 1


v0.0.48 (Wed Aug 30 2023)

🐛 Bug Fix

Authors: 2


v0.0.47 (Wed Aug 30 2023)

🐛 Bug Fix

Authors: 1


v0.0.46 (Tue Aug 29 2023)

🐛 Bug Fix

  • Fix: Updates the the link to the Visual Testing addon documentation #61 (@jonniebigodes)

📝 Documentation

Authors: 1


v0.0.45 (Tue Aug 29 2023)

🐛 Bug Fix

Authors: 1


v0.0.44 (Tue Aug 29 2023)

🐛 Bug Fix

Authors: 1


v0.0.43 (Tue Aug 29 2023)

🐛 Bug Fix

Authors: 1


v0.0.42 (Tue Aug 29 2023)

🐛 Bug Fix

Authors: 4


v0.0.41 (Tue Aug 29 2023)

🐛 Bug Fix

  • Show instructional UI if main.js updating fails #41 (@tmeasday)

Authors: 1


v0.0.40 (Sat Aug 26 2023)

🐛 Bug Fix

  • Add SidebarBottom to toggle sidebar filtering based on story status #45 (@ghengeveld)

Authors: 1


v0.0.39 (Sat Aug 26 2023)

🐛 Bug Fix

  • Update selectedTest whenever tests change (e.g. when switching stories) #51 (@ghengeveld)

Authors: 1


v0.0.38 (Fri Aug 25 2023)

🐛 Bug Fix

Authors: 1


v0.0.37 (Fri Aug 25 2023)

🐛 Bug Fix

  • Allow passing buildScriptName as addon option #44 (@tmeasday)

Authors: 1


v0.0.36 (Thu Aug 24 2023)

🐛 Bug Fix

  • Always show last (potentially local) build on branch #46 (@ghengeveld)

Authors: 1


v0.0.35 (Thu Aug 24 2023)

🐛 Bug Fix

  • Read configDir and use for main.js location #39 (@tmeasday)

Authors: 1


v0.0.34 (Wed Aug 23 2023)

🐛 Bug Fix

  • add story for baselineImageVisible: true on SnapshotComparison #47 (@weeksling)

Authors: 1


v0.0.33 (Wed Aug 23 2023)

🐛 Bug Fix

Authors: 1


v0.0.32 (Wed Aug 23 2023)

🐛 Bug Fix

  • Refactor SnapshotImage to handle overlay images and scaling #40 (@ghengeveld)

Authors: 1


v0.0.31 (Wed Aug 23 2023)

🐛 Bug Fix

Authors: 1


v0.0.30 (Tue Aug 22 2023)

🐛 Bug Fix

Authors: 1


v0.0.29 (Tue Aug 22 2023)

🐛 Bug Fix

  • Query testsForStory and testsForStatus separately to avoid pagination #37 (@ghengeveld)

Authors: 1


v0.0.28 (Tue Aug 22 2023)

🐛 Bug Fix

  • Remove/hide render settings and warnings screens for now #43 (@ghengeveld)

Authors: 1


v0.0.27 (Tue Aug 22 2023)

🐛 Bug Fix

Authors: 3


v0.0.26 (Tue Aug 22 2023)

🐛 Bug Fix

  • Don't show the SnapshotComparison for skipped stories #33 (@tmeasday)

Authors: 1


v0.0.25 (Mon Aug 21 2023)

🐛 Bug Fix

Authors: 1


v0.0.24 (Fri Aug 18 2023)

🐛 Bug Fix

Authors: 1


v0.0.23 (Thu Aug 17 2023)

🐛 Bug Fix

Authors: 1


v0.0.22 (Wed Aug 16 2023)

🐛 Bug Fix

  • Poll for Git repository hash and set isOutdated when it changes #31 (@ghengeveld)

Authors: 1


v0.0.21 (Wed Aug 16 2023)

🐛 Bug Fix

Authors: 1


v0.0.20 (Mon Aug 14 2023)

🐛 Bug Fix

Authors: 1


v0.0.19 (Thu Aug 10 2023)

🐛 Bug Fix

Authors: 1


v0.0.18 (Wed Aug 09 2023)

🐛 Bug Fix

Authors: 1


v0.0.17 (Mon Aug 07 2023)

🐛 Bug Fix

Authors: 1


v0.0.16 (Tue Aug 01 2023)

🐛 Bug Fix

  • Show reviewing errors in browser console and improve dev setup #21 (@tmeasday)

Authors: 1


v0.0.15 (Thu Jul 27 2023)

🐛 Bug Fix

⚠️ Pushed to main

Authors: 5