@crvy/strybk 0.0.6 → 0.0.7
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/CHANGELOG.md +19 -0
- package/README.md +2 -0
- package/dist/src/generate/render.js +35 -14
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.0.7] - 2026-08-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Nest one describe per story title segment
|
|
13
|
+
|
|
14
|
+
### Documentation
|
|
15
|
+
|
|
16
|
+
- Add nested describe titles design spec
|
|
17
|
+
- Add nested describe titles implementation plan
|
|
18
|
+
- Note nested describes and --grep caveat
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Escape backslashes in generated titles and story names
|
|
23
|
+
|
|
24
|
+
### Miscellaneous
|
|
25
|
+
|
|
26
|
+
- Upgrade bun to 1.4.0
|
|
8
27
|
## [0.0.6] - 2026-08-24
|
|
9
28
|
|
|
10
29
|
### Added
|
package/README.md
CHANGED
|
@@ -40,6 +40,8 @@ export default defineConfig({
|
|
|
40
40
|
|
|
41
41
|
Each generated spec renders a Playwright test per story. At runtime, `parameters.creevey` (read from the running Storybook, merged across global / kind / story levels) drives capture and skip behavior — no Storybook addon required:
|
|
42
42
|
|
|
43
|
+
Generated suites nest one `test.describe` per title segment — `Components/Button` becomes `describe('Components') > describe('Button')` — so the Playwright HTML reporter shows a collapsible tree. Snapshot filenames are unaffected. Note that `--grep` patterns containing `/` no longer match (Playwright greps the space-joined title path); grep by a single segment instead, e.g. `--grep CommentLine`.
|
|
44
|
+
|
|
43
45
|
- `captureElement: '<selector>'` — captures `page.locator('<selector>')`.
|
|
44
46
|
- `captureElement: null` (or unset) — captures the viewport.
|
|
45
47
|
- `skip: { '<reason>': { in, kinds, stories } }` — marks the test skipped with `<reason>`. Note: `in` matches the **Playwright project name** (not the browser engine), so with the default project name `chromium`, a rule like `{ in: 'chrome' }` won't match — name your Playwright projects to line up with your `in:` rules, or scope rules via `kinds`/`stories`.
|
|
@@ -1,17 +1,38 @@
|
|
|
1
|
-
const escapeSingleQuotes = (value) => value.replace(/'/gu, "\\'");
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
const escapeSingleQuotes = (value) => value.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'");
|
|
2
|
+
const splitTitleSegments = (title) => title
|
|
3
|
+
.split("/")
|
|
4
|
+
.map((segment) => segment.trim())
|
|
5
|
+
.filter((segment) => segment.length > 0);
|
|
6
|
+
const renderTest = (story, depth) => {
|
|
7
|
+
const indent = " ".repeat(depth);
|
|
8
|
+
return [
|
|
9
|
+
`${indent}test('${escapeSingleQuotes(story.name)}', async ({ sharedPage, creevey }) => {`,
|
|
10
|
+
`${indent} const { skip, reason, captureElement, ignoreElements } = creevey.params('${story.id}');`,
|
|
11
|
+
`${indent} test.skip(skip, reason);`,
|
|
12
|
+
`${indent} await switchStory(sharedPage, '${story.id}');`,
|
|
13
|
+
`${indent} const target = captureElement ? sharedPage.locator(captureElement) : sharedPage;`,
|
|
14
|
+
`${indent} await expect(target).toHaveScreenshot({`,
|
|
15
|
+
`${indent} mask: ignoreElements.map((selector) => sharedPage.locator(selector)),`,
|
|
16
|
+
`${indent} });`,
|
|
17
|
+
`${indent}});`,
|
|
18
|
+
].join("\n");
|
|
19
|
+
};
|
|
20
|
+
const wrapInDescribes = (segments, tests, depth) => {
|
|
21
|
+
const indent = " ".repeat(depth);
|
|
22
|
+
const [segment, ...rest] = segments;
|
|
23
|
+
if (segment === undefined) {
|
|
24
|
+
return tests;
|
|
25
|
+
}
|
|
26
|
+
return [
|
|
27
|
+
`${indent}test.describe('${escapeSingleQuotes(segment)}', () => {`,
|
|
28
|
+
wrapInDescribes(rest, tests, depth + 1),
|
|
29
|
+
`${indent}});`,
|
|
30
|
+
].join("\n");
|
|
31
|
+
};
|
|
13
32
|
export function renderScreenshotSpec(args) {
|
|
14
33
|
const generatedRegionName = args.config.generatedRegionName ?? "auto-screenshots";
|
|
15
|
-
const
|
|
16
|
-
|
|
34
|
+
const segments = splitTitleSegments(args.title);
|
|
35
|
+
const tests = args.stories.map((story) => renderTest(story, segments.length)).join("\n\n");
|
|
36
|
+
const body = wrapInDescribes(segments, tests, 0);
|
|
37
|
+
return `import { test, expect, switchStory } from '@crvy/strybk';\n\n// @generated-begin ${generatedRegionName}\n${body}\n// @generated-end ${generatedRegionName}\n\n${args.manualRegion}`;
|
|
17
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvy/strybk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Generator-first Playwright screenshot testing for Storybook.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crvy",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@playwright/test": "1.59.1",
|
|
75
|
-
"@types/bun": "^1.
|
|
75
|
+
"@types/bun": "^1.4.0",
|
|
76
76
|
"@types/node": "25.9.0",
|
|
77
77
|
"git-cliff": "2.13.1",
|
|
78
78
|
"jscpd": "^4.0.8",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"@playwright/test": ">=1.59.0"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
|
-
"bun": ">=1.
|
|
91
|
+
"bun": ">=1.4.0",
|
|
92
92
|
"node": ">=22"
|
|
93
93
|
},
|
|
94
|
-
"packageManager": "bun@1.
|
|
94
|
+
"packageManager": "bun@1.4.0"
|
|
95
95
|
}
|