@iqual/playwright-vrt 0.1.1 → 0.1.3

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.
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env bun
2
+ import type { VRTConfig } from './config.js';
3
+ export interface TestResults {
4
+ passed: number;
5
+ failed: number;
6
+ total: number;
7
+ exitCode: number;
8
+ }
9
+ export interface RunnerOptions {
10
+ config: VRTConfig;
11
+ outputDir: string;
12
+ verbose?: boolean;
13
+ project?: string;
14
+ updateBaseline?: boolean;
15
+ hasExplicitReference?: boolean;
16
+ headed?: boolean;
17
+ }
18
+ /**
19
+ * Check if baseline snapshots already exist and are valid
20
+ */
21
+ export declare function hasExistingSnapshots(snapshotDir: string): boolean;
22
+ /**
23
+ * Run Playwright tests using the shipped config and test files
24
+ * Much simpler than the old approach - just exec playwright
25
+ */
26
+ export declare function runVisualTests(options: RunnerOptions): Promise<TestResults>;
27
+ export declare function printResults(results: TestResults, config: VRTConfig): void;
28
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAyBjE;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CA0DjF;AA4GD,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAW1E"}
@@ -0,0 +1,182 @@
1
+ #!/usr/bin/env bun
2
+ import { spawn } from 'child_process';
3
+ import * as path from 'path';
4
+ import * as fs from 'fs';
5
+ /**
6
+ * Check if baseline snapshots already exist and are valid
7
+ */
8
+ export function hasExistingSnapshots(snapshotDir) {
9
+ if (!fs.existsSync(snapshotDir)) {
10
+ return false;
11
+ }
12
+ // Recursively check for any .png files
13
+ function hasSnapshotFiles(dir) {
14
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
15
+ for (const entry of entries) {
16
+ const fullPath = path.join(dir, entry.name);
17
+ if (entry.isDirectory()) {
18
+ if (hasSnapshotFiles(fullPath)) {
19
+ return true;
20
+ }
21
+ }
22
+ else if (entry.name.endsWith('.png')) {
23
+ return true;
24
+ }
25
+ }
26
+ return false;
27
+ }
28
+ return hasSnapshotFiles(snapshotDir);
29
+ }
30
+ /**
31
+ * Run Playwright tests using the shipped config and test files
32
+ * Much simpler than the old approach - just exec playwright
33
+ */
34
+ export async function runVisualTests(options) {
35
+ const { config, outputDir, verbose, project, updateBaseline, hasExplicitReference, headed } = options;
36
+ // Find the playwright-vrt package directory
37
+ const packageDir = path.join(__dirname, '..');
38
+ const playwrightConfigPath = path.join(packageDir, 'playwright.config.js');
39
+ const snapshotDir = path.join(process.cwd(), 'playwright-snapshots');
40
+ // Check if baseline snapshots already exist (look for any .png files in snapshots)
41
+ const hasBaseline = !updateBaseline && hasExistingSnapshots(snapshotDir);
42
+ if (hasBaseline) {
43
+ console.log('\n📸 Using existing baseline snapshots');
44
+ if (verbose) {
45
+ console.log(' (Use --update-baseline to regenerate from reference URL)');
46
+ }
47
+ }
48
+ else {
49
+ if (updateBaseline) {
50
+ console.log('\n🔄 Updating baseline snapshots...');
51
+ }
52
+ else {
53
+ console.log('\n📸 Creating baseline snapshots (first run)...');
54
+ }
55
+ console.log(` Source: ${config.referenceUrl}`);
56
+ // Step 1: Create baseline screenshots
57
+ await runPlaywright({
58
+ configPath: playwrightConfigPath,
59
+ baseURL: config.referenceUrl,
60
+ vrtConfig: config,
61
+ outputDir,
62
+ updateSnapshots: true,
63
+ verbose: true,
64
+ project,
65
+ headed,
66
+ });
67
+ console.log('✓ Baseline created');
68
+ }
69
+ console.log(`\n🧪 Testing ${config.testUrl}`);
70
+ // Step 2: Run tests against test URL
71
+ const exitCode = await runPlaywright({
72
+ configPath: playwrightConfigPath,
73
+ baseURL: config.testUrl,
74
+ vrtConfig: config,
75
+ outputDir,
76
+ updateSnapshots: false,
77
+ verbose: true,
78
+ project,
79
+ headed,
80
+ });
81
+ // Parse results
82
+ const results = await parseResults(outputDir);
83
+ results.exitCode = exitCode;
84
+ return results;
85
+ }
86
+ async function runPlaywright(options) {
87
+ return new Promise((resolve, reject) => {
88
+ const args = [
89
+ 'playwright',
90
+ 'test',
91
+ '--config', options.configPath
92
+ ];
93
+ if (options.updateSnapshots) {
94
+ args.push('--update-snapshots');
95
+ }
96
+ if (options.project) {
97
+ args.push('--project', options.project);
98
+ }
99
+ if (options.headed) {
100
+ args.push('--headed');
101
+ }
102
+ const env = {
103
+ ...process.env,
104
+ BASE_URL: options.baseURL,
105
+ VRT_CONFIG: JSON.stringify(options.vrtConfig),
106
+ OUTPUT_DIR: options.outputDir,
107
+ };
108
+ const proc = spawn('bunx', args, {
109
+ env,
110
+ stdio: options.verbose ? 'inherit' : 'pipe',
111
+ shell: true,
112
+ cwd: process.cwd(),
113
+ });
114
+ let stdout = '';
115
+ let stderr = '';
116
+ if (!options.verbose) {
117
+ proc.stdout?.on('data', (data) => {
118
+ stdout += data.toString();
119
+ });
120
+ proc.stderr?.on('data', (data) => {
121
+ stderr += data.toString();
122
+ });
123
+ }
124
+ proc.on('close', (code) => {
125
+ const exitCode = code || 0;
126
+ // For baseline creation (update-snapshots), always succeed
127
+ if (options.updateSnapshots) {
128
+ resolve(0);
129
+ }
130
+ else {
131
+ // For actual tests, return the exit code
132
+ resolve(exitCode);
133
+ }
134
+ });
135
+ proc.on('error', (error) => {
136
+ reject(new Error(`Failed to run Playwright: ${error.message}`));
137
+ });
138
+ });
139
+ }
140
+ async function parseResults(outputDir) {
141
+ const resultsPath = path.join(outputDir, 'results.json');
142
+ try {
143
+ const file = Bun.file(resultsPath);
144
+ const results = await file.json();
145
+ let passed = 0;
146
+ let failed = 0;
147
+ let total = 0;
148
+ // Parse Playwright JSON results
149
+ if (results.suites) {
150
+ for (const suite of results.suites) {
151
+ if (suite.specs) {
152
+ for (const spec of suite.specs) {
153
+ total++;
154
+ if (spec.ok) {
155
+ passed++;
156
+ }
157
+ else {
158
+ failed++;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+ return { passed, failed, total, exitCode: 0 };
165
+ }
166
+ catch {
167
+ return { passed: 0, failed: 0, total: 0, exitCode: 1 };
168
+ }
169
+ }
170
+ export function printResults(results, config) {
171
+ console.log('\n📊 Test Results:');
172
+ console.log(` Total: ${results.total}`);
173
+ console.log(` Passed: ${results.passed}`);
174
+ console.log(` Failed: ${results.failed}`);
175
+ if (results.failed > 0) {
176
+ console.log(`\n❌ ${results.failed} visual difference(s) detected`);
177
+ }
178
+ else if (results.total > 0) {
179
+ console.log('\n✅ All visual tests passed');
180
+ }
181
+ }
182
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AA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@@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Workspace manages the .playwright-vrt/ directory
4
+ * This is persistent between runs for debugging and caching
5
+ */
6
+ export declare class Workspace {
7
+ private readonly dir;
8
+ constructor(baseDir?: string);
9
+ getPath(file?: string): string;
10
+ writeFile(filename: string, content: string): void;
11
+ readFile(filename: string): string;
12
+ exists(filename: string): boolean;
13
+ writeJSON(filename: string, data: any): void;
14
+ readJSON(filename: string): any;
15
+ clean(): void;
16
+ info(): void;
17
+ }
18
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/workspace.ts"],"names":[],"mappings":";AAKA;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;gBAEjB,OAAO,CAAC,EAAE,MAAM;IAQ5B,OAAO,CAAC,IAAI,GAAE,MAAW,GAAG,MAAM;IAIlC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAWlD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAKlC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIjC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI;IAI5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG;IAK/B,KAAK,IAAI,IAAI;IAOb,IAAI,IAAI,IAAI;CAGb"}
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env bun
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ /**
5
+ * Workspace manages the .playwright-vrt/ directory
6
+ * This is persistent between runs for debugging and caching
7
+ */
8
+ export class Workspace {
9
+ dir;
10
+ constructor(baseDir) {
11
+ // Use .playwright-vrt in current directory (or specified base)
12
+ this.dir = path.join(baseDir || process.cwd(), '.playwright-vrt');
13
+ // Create workspace directory
14
+ fs.mkdirSync(this.dir, { recursive: true });
15
+ }
16
+ getPath(file = '') {
17
+ return file ? path.join(this.dir, file) : this.dir;
18
+ }
19
+ writeFile(filename, content) {
20
+ const filePath = this.getPath(filename);
21
+ const dir = path.dirname(filePath);
22
+ if (!fs.existsSync(dir)) {
23
+ fs.mkdirSync(dir, { recursive: true });
24
+ }
25
+ fs.writeFileSync(filePath, content, 'utf-8');
26
+ }
27
+ readFile(filename) {
28
+ const filePath = this.getPath(filename);
29
+ return fs.readFileSync(filePath, 'utf-8');
30
+ }
31
+ exists(filename) {
32
+ return fs.existsSync(this.getPath(filename));
33
+ }
34
+ writeJSON(filename, data) {
35
+ this.writeFile(filename, JSON.stringify(data, null, 2));
36
+ }
37
+ readJSON(filename) {
38
+ return JSON.parse(this.readFile(filename));
39
+ }
40
+ // Manual cleanup - workspace is persistent by default
41
+ clean() {
42
+ if (fs.existsSync(this.dir)) {
43
+ fs.rmSync(this.dir, { recursive: true, force: true });
44
+ console.log(`🗑️ Cleaned workspace: ${this.dir}`);
45
+ }
46
+ }
47
+ info() {
48
+ console.log(`📁 Workspace: ${this.dir}`);
49
+ }
50
+ }
51
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/workspace.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;GAGG;AACH,MAAM,OAAO,SAAS;IACH,GAAG,CAAS;IAE7B,YAAY,OAAgB;QAC1B,+DAA+D;QAC/D,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAElE,6BAA6B;QAC7B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC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,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACtD,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAED,IAAI;QACF,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF"}
@@ -9,7 +9,7 @@ if (!existsSync(urlsPath)) {
9
9
  throw new Error(`URLs file not found at ${urlsPath}. Did you run URL collection?`);
10
10
  }
11
11
 
12
- const urls: string[] = JSON.parse(readFileSync(urlsPath, 'utf-8'));
12
+ const urls = JSON.parse(readFileSync(urlsPath, 'utf-8'));
13
13
 
14
14
  // Load config for threshold settings
15
15
  const vrtConfig = process.env.VRT_CONFIG
@@ -47,7 +47,8 @@ for (const url of urls) {
47
47
  maxDiffPixels: threshold.maxDiffPixels,
48
48
  maxDiffPixelRatio: threshold.maxDiffPixelRatio,
49
49
  animations: 'disabled',
50
- stylePath: join(process.cwd(), 'tests', 'vrt.css')
51
- }, { timeout: 10000 });
50
+ stylePath: join(process.cwd(), 'tests', 'vrt.css'),
51
+ timeout: 10000
52
+ });
52
53
  });
53
54
  }
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "@iqual/playwright-vrt",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Standalone Visual Regression Testing CLI tool using Playwright",
5
5
  "type": "module",
6
6
  "bin": {
7
- "playwright-vrt": "./src/cli.ts"
7
+ "playwright-vrt": "./dist/src/cli.js"
8
8
  },
9
9
  "files": [
10
- "src/",
11
- "tests/",
12
- "playwright.config.ts",
13
- "tsconfig.json",
10
+ "dist/",
14
11
  "README.md"
15
12
  ],
16
13
  "scripts": {
17
14
  "dev": "bun run src/cli.ts",
15
+ "build": "tsc && cp -r tests dist/ && cp playwright.config.js dist/",
16
+ "clean": "rm -rf dist",
18
17
  "typecheck": "tsc --noEmit",
19
- "prepublishOnly": "bun run typecheck",
20
- "test": "bun run src/cli.ts --help"
18
+ "prepublishOnly": "bun run clean && bun run build",
19
+ "test": "bun run src/cli.ts --help",
20
+ "test:dist": "node dist/src/cli.js --help"
21
21
  },
22
22
  "keywords": [
23
23
  "visual-regression",