@storywright/cli 0.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/LICENSE +21 -0
- package/bin/storywright.mjs +2 -0
- package/dist/chunk-FST75QN5.js +136 -0
- package/dist/chunk-FST75QN5.js.map +1 -0
- package/dist/chunk-U4KT4Y42.js +748 -0
- package/dist/chunk-U4KT4Y42.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +363 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +134 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/playwright/reporter.d.ts +18 -0
- package/dist/playwright/reporter.js +9 -0
- package/dist/playwright/reporter.js.map +1 -0
- package/dist/types-DqV0YrhZ.d.ts +45 -0
- package/package.json +62 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createStorageAdapter,
|
|
3
|
+
defineConfig,
|
|
4
|
+
formatSummary,
|
|
5
|
+
loadConfig,
|
|
6
|
+
runTests,
|
|
7
|
+
updateBaselines
|
|
8
|
+
} from "./chunk-U4KT4Y42.js";
|
|
9
|
+
|
|
10
|
+
// src/core/index.ts
|
|
11
|
+
import path from "path";
|
|
12
|
+
async function createStorywright(userConfig, cwd = process.cwd()) {
|
|
13
|
+
const config = await loadConfig(cwd, userConfig);
|
|
14
|
+
return {
|
|
15
|
+
async test(options = {}) {
|
|
16
|
+
const overrides = {};
|
|
17
|
+
if (options.browsers) {
|
|
18
|
+
overrides.browsers = options.browsers;
|
|
19
|
+
}
|
|
20
|
+
const mergedConfig = options.browsers ? await loadConfig(cwd, { ...userConfig, ...overrides }) : config;
|
|
21
|
+
return runTests(
|
|
22
|
+
mergedConfig,
|
|
23
|
+
{
|
|
24
|
+
diffOnly: options.diffOnly,
|
|
25
|
+
shard: options.shard,
|
|
26
|
+
filter: options.filter
|
|
27
|
+
},
|
|
28
|
+
cwd
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
async update(options = {}) {
|
|
32
|
+
await updateBaselines(config, { all: options.all }, cwd);
|
|
33
|
+
},
|
|
34
|
+
async upload() {
|
|
35
|
+
const storage = createStorageAdapter(config.storage);
|
|
36
|
+
await storage.upload({
|
|
37
|
+
branch: "current",
|
|
38
|
+
sourceDir: path.resolve(cwd, config.storage.local.baselineDir)
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
async download(options = {}) {
|
|
42
|
+
const storage = createStorageAdapter(config.storage);
|
|
43
|
+
await storage.download({
|
|
44
|
+
branch: options.branch ?? "main",
|
|
45
|
+
destDir: path.resolve(cwd, config.storage.local.baselineDir)
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
generateReport(result) {
|
|
49
|
+
if (result.summary) {
|
|
50
|
+
const reportPath = result.reportDir ? `${result.reportDir}/index.html` : void 0;
|
|
51
|
+
return formatSummary(result.summary, { reportPath });
|
|
52
|
+
}
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
createStorywright,
|
|
59
|
+
defineConfig,
|
|
60
|
+
loadConfig
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/index.ts"],"sourcesContent":["import path from 'node:path';\nimport { loadConfig } from '../config/index.js';\nimport type { DeepPartial, StorywrightConfig } from '../config/types.js';\nimport { formatSummary } from '../reporter/cli-reporter.js';\nimport { createStorageAdapter } from '../storage/index.js';\nimport { type TestRunResult, runTests, updateBaselines } from './engine.js';\n\nexport interface Storywright {\n\ttest(options?: {\n\t\tdiffOnly?: boolean;\n\t\tbrowsers?: string[];\n\t\tshard?: string;\n\t\tfilter?: string;\n\t}): Promise<TestRunResult>;\n\n\tupdate(options?: { all?: boolean }): Promise<void>;\n\tupload(): Promise<void>;\n\tdownload(options?: { branch?: string }): Promise<void>;\n\tgenerateReport(result: TestRunResult): string | undefined;\n}\n\nexport async function createStorywright(\n\tuserConfig?: DeepPartial<StorywrightConfig>,\n\tcwd: string = process.cwd(),\n): Promise<Storywright> {\n\tconst config = await loadConfig(cwd, userConfig);\n\n\treturn {\n\t\tasync test(options = {}) {\n\t\t\tconst overrides: DeepPartial<StorywrightConfig> = {};\n\t\t\tif (options.browsers) {\n\t\t\t\toverrides.browsers = options.browsers;\n\t\t\t}\n\t\t\tconst mergedConfig = options.browsers\n\t\t\t\t? await loadConfig(cwd, { ...userConfig, ...overrides })\n\t\t\t\t: config;\n\n\t\t\treturn runTests(\n\t\t\t\tmergedConfig,\n\t\t\t\t{\n\t\t\t\t\tdiffOnly: options.diffOnly,\n\t\t\t\t\tshard: options.shard,\n\t\t\t\t\tfilter: options.filter,\n\t\t\t\t},\n\t\t\t\tcwd,\n\t\t\t);\n\t\t},\n\n\t\tasync update(options = {}) {\n\t\t\tawait updateBaselines(config, { all: options.all }, cwd);\n\t\t},\n\n\t\tasync upload() {\n\t\t\tconst storage = createStorageAdapter(config.storage);\n\t\t\tawait storage.upload({\n\t\t\t\tbranch: 'current',\n\t\t\t\tsourceDir: path.resolve(cwd, config.storage.local.baselineDir),\n\t\t\t});\n\t\t},\n\n\t\tasync download(options = {}) {\n\t\t\tconst storage = createStorageAdapter(config.storage);\n\t\t\tawait storage.download({\n\t\t\t\tbranch: options.branch ?? 'main',\n\t\t\t\tdestDir: path.resolve(cwd, config.storage.local.baselineDir),\n\t\t\t});\n\t\t},\n\n\t\tgenerateReport(result: TestRunResult): string | undefined {\n\t\t\tif (result.summary) {\n\t\t\t\tconst reportPath = result.reportDir ? `${result.reportDir}/index.html` : undefined;\n\t\t\t\treturn formatSummary(result.summary, { reportPath });\n\t\t\t}\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAO,UAAU;AAqBjB,eAAsB,kBACrB,YACA,MAAc,QAAQ,IAAI,GACH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
import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
|
|
2
|
+
import { T as TestSummary } from '../types-DqV0YrhZ.js';
|
|
3
|
+
|
|
4
|
+
interface StorywrightReporterOptions {
|
|
5
|
+
outputDir?: string;
|
|
6
|
+
}
|
|
7
|
+
declare class StorywrightReporter implements Reporter {
|
|
8
|
+
private outputDir;
|
|
9
|
+
private results;
|
|
10
|
+
private startTime;
|
|
11
|
+
constructor(options?: StorywrightReporterOptions);
|
|
12
|
+
onBegin(_config: FullConfig, _suite: Suite): void;
|
|
13
|
+
onTestEnd(test: TestCase, result: TestResult): void;
|
|
14
|
+
onEnd(_result: FullResult): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
declare function generateHtmlReport(summary: TestSummary): string;
|
|
17
|
+
|
|
18
|
+
export { StorywrightReporter as default, generateHtmlReport };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
interface Story {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
name: string;
|
|
5
|
+
importPath: string;
|
|
6
|
+
tags?: string[];
|
|
7
|
+
type: 'story' | 'docs';
|
|
8
|
+
}
|
|
9
|
+
interface StoryIndex {
|
|
10
|
+
v: number;
|
|
11
|
+
entries: Record<string, Story>;
|
|
12
|
+
}
|
|
13
|
+
interface TestResult {
|
|
14
|
+
story: Story;
|
|
15
|
+
browser: string;
|
|
16
|
+
status: 'passed' | 'failed' | 'skipped';
|
|
17
|
+
duration: number;
|
|
18
|
+
diffRatio?: number;
|
|
19
|
+
expectedPath?: string;
|
|
20
|
+
actualPath?: string;
|
|
21
|
+
diffPath?: string;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
interface TestSummary {
|
|
25
|
+
total: number;
|
|
26
|
+
passed: number;
|
|
27
|
+
failed: number;
|
|
28
|
+
skipped: number;
|
|
29
|
+
duration: number;
|
|
30
|
+
timestamp: string;
|
|
31
|
+
browsers: string[];
|
|
32
|
+
failures: FailureEntry[];
|
|
33
|
+
}
|
|
34
|
+
interface FailureEntry {
|
|
35
|
+
type: 'diff' | 'new';
|
|
36
|
+
story: string;
|
|
37
|
+
variant: string;
|
|
38
|
+
browser: string;
|
|
39
|
+
diffRatio: number;
|
|
40
|
+
expected: string;
|
|
41
|
+
actual: string;
|
|
42
|
+
diff: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { FailureEntry as F, Story as S, TestSummary as T, TestResult as a, StoryIndex as b };
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@storywright/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zero-config visual regression testing powered by Storybook + Playwright",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"storywright": "./bin/storywright.mjs"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./playwright/reporter": {
|
|
16
|
+
"import": "./dist/playwright/reporter.js",
|
|
17
|
+
"types": "./dist/playwright/reporter.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"bin"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"citty": "^0.1.6",
|
|
29
|
+
"consola": "^3.2.3",
|
|
30
|
+
"sirv": "^3.0.0",
|
|
31
|
+
"simple-git": "^3.27.0",
|
|
32
|
+
"unconfig": "^0.6.0",
|
|
33
|
+
"picomatch": "^4.0.2",
|
|
34
|
+
"@storywright/report": "0.1.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@playwright/test": "^1.50.0",
|
|
38
|
+
"@types/node": "^22.0.0",
|
|
39
|
+
"@types/picomatch": "^3.0.1",
|
|
40
|
+
"tsup": "^8.3.0",
|
|
41
|
+
"typescript": "^5.6.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@playwright/test": ">=1.40.0"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18.0.0"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"storybook",
|
|
51
|
+
"playwright",
|
|
52
|
+
"visual-regression-testing",
|
|
53
|
+
"screenshot",
|
|
54
|
+
"vrt",
|
|
55
|
+
"testing"
|
|
56
|
+
],
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"dev": "tsup --watch"
|
|
61
|
+
}
|
|
62
|
+
}
|