stateofpixel 1.0.0 → 1.2.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 +38 -2
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +160 -553
- package/dist/index.mjs.map +1 -1
- package/dist/playwright.d.mts +27 -0
- package/dist/playwright.mjs +81 -0
- package/dist/playwright.mjs.map +1 -0
- package/dist/upload-DKzFVTAz.mjs +575 -0
- package/dist/upload-DKzFVTAz.mjs.map +1 -0
- package/package.json +19 -1
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.
|
|
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.
|
|
@@ -39,6 +66,15 @@ When the count is not known, each job runs `stateofpixel upload screenshots --sh
|
|
|
39
66
|
|
|
40
67
|
## Service errors
|
|
41
68
|
|
|
42
|
-
When the service is down, `upload` and `finalize` print a warning and exit 0, so our outage does not break your CI. Pass `--strict` to fail instead.
|
|
69
|
+
When the service is down, or a rate limit is hit, `upload` and `finalize` print a warning and exit 0, so our outage does not break your CI. Pass `--strict` to fail instead.
|
|
70
|
+
|
|
71
|
+
## Limits
|
|
72
|
+
|
|
73
|
+
- 20,000 snapshots and 256 shards per build.
|
|
74
|
+
- 20 MB and 10,000 x 50,000 px per image. Bigger images are rejected, their snapshots fail and `upload` exits 1.
|
|
75
|
+
- 512 characters per snapshot name, 4 KB of metadata per snapshot.
|
|
76
|
+
- 2,000 builds and 20 GB of uploads per account per day, 600 requests per minute per token.
|
|
77
|
+
|
|
78
|
+
When an account passes 80% of its storage, the CLI prints a warning. After 14 days over the limit, new images are not stored and the check is neutral, so CI keeps passing.
|
|
43
79
|
|
|
44
80
|
Requires Node 20 or newer.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|