stateofpixel 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,18 +19,45 @@ steps:
19
19
  - run: npx stateofpixel upload screenshots
20
20
  ```
21
21
 
22
- On other CI, set `STATEOFPIXEL_TOKEN` to a project token. Creating tokens in the web app comes with the project settings page.
22
+ On other CI, set `STATEOFPIXEL_TOKEN` to a project token. Admins create tokens in the project settings on stateofpixel.com.
23
23
 
24
24
  ## Commands
25
25
 
26
26
  | Command | Purpose |
27
27
  |---|---|
28
28
  | `stateofpixel upload <dir>` | Upload a folder of PNGs and compare it with the baseline. |
29
+ | `stateofpixel storybook <static-dir>` | Capture every story of a built Storybook, then upload. |
29
30
  | `stateofpixel finalize` | Finish a build whose shards ran with `--shard auto`. |
30
31
  | `stateofpixel compare <dir> <baseline-dir>` | Compare two folders locally and write `stateofpixel-report/index.html`. |
31
32
 
32
33
  Run `stateofpixel <command> --help` for every flag.
33
34
 
35
+ A `<name>.meta.json` next to `<name>.png` is sent as that snapshot's metadata and shown on the review page.
36
+
37
+ ## Storybook
38
+
39
+ `storybook` and the Playwright reporter need Playwright in your project: `npm install -D playwright`, then `npx playwright install chromium`.
40
+
41
+ ```yaml
42
+ - run: npx storybook build
43
+ - run: npx stateofpixel storybook storybook-static --viewports 375,1280
44
+ ```
45
+
46
+ Each story is captured at every viewport width and named `Title/Name [chromium 1280]`. Filter with `--include` and `--exclude` globs on `Title/Name`, and use `--wait-for-selector` and `--delay` for stories that render late.
47
+
48
+ ## Playwright
49
+
50
+ ```ts
51
+ // playwright.config.ts
52
+ reporter: [["list"], ["stateofpixel/playwright"]]
53
+
54
+ // in a test
55
+ import { snapshot } from "stateofpixel/playwright";
56
+ await snapshot(page, "Checkout/Empty cart");
57
+ ```
58
+
59
+ `snapshot` waits for fonts, disables animations, hides the caret, and saves a full-page screenshot named `Checkout/Empty cart [chromium 1280]` into `stateofpixel-screenshots`. The reporter uploads that folder when the run ends, once per shard when Playwright sharding is on. It uploads on CI only (when `CI` is set); pass `{ uploadOutsideCi: true }` as reporter options to upload from your machine. When a test fails, the upload is marked as a subset so skipped snapshots are not reported as removed.
60
+
34
61
  ## Sharding
35
62
 
36
63
  With a known shard count, each job runs `stateofpixel upload screenshots --shard 1/4` through `4/4`, and the build finishes when the last shard is done.
@@ -0,0 +1 @@
1
+ export {}