@vizzly-testing/cli 0.11.2 → 0.12.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.
@@ -1,5 +1,6 @@
1
1
  import { writeFileSync, readFileSync, existsSync, mkdirSync } from 'fs';
2
2
  import { join } from 'path';
3
+ import { compare } from '@vizzly-testing/honeydiff';
3
4
  import { ApiService } from '../services/api-service.js';
4
5
  import { createServiceLogger } from '../utils/logger-factory.js';
5
6
  import { colors } from '../utils/colors.js';
@@ -549,23 +550,21 @@ export class TddService {
549
550
 
550
551
  // Baseline exists - compare with it
551
552
  try {
552
- // Use odiff Node.js API to compare images
553
- const {
554
- compare
555
- } = await import('odiff-bin');
556
-
557
553
  // Log file sizes for debugging
558
554
  const baselineSize = readFileSync(baselineImagePath).length;
559
555
  const currentSize = readFileSync(currentImagePath).length;
560
556
  logger.debug(`Comparing ${sanitizedName}`);
561
557
  logger.debug(`Baseline: ${baselineImagePath} (${baselineSize} bytes)`);
562
558
  logger.debug(`Current: ${currentImagePath} (${currentSize} bytes)`);
563
- const result = await compare(baselineImagePath, currentImagePath, diffImagePath, {
564
- threshold: this.threshold,
565
- outputDiffMask: true,
566
- failOnLayoutDiff: true // Fail if image dimensions differ
559
+ const result = await compare(baselineImagePath, currentImagePath, {
560
+ colorThreshold: this.threshold,
561
+ // YIQ color threshold (0.0-1.0), default 0.1
562
+ antialiasing: true,
563
+ diffPath: diffImagePath,
564
+ overwrite: true,
565
+ includeClusters: true // Enable spatial clustering analysis
567
566
  });
568
- if (result.match) {
567
+ if (!result.isDifferent) {
569
568
  // Images match
570
569
  const comparison = {
571
570
  name: sanitizedName,
@@ -574,18 +573,22 @@ export class TddService {
574
573
  current: currentImagePath,
575
574
  diff: null,
576
575
  properties: validatedProperties,
577
- threshold: this.threshold
576
+ threshold: this.threshold,
577
+ // Include honeydiff metrics even for passing comparisons
578
+ totalPixels: result.totalPixels,
579
+ aaPixelsIgnored: result.aaPixelsIgnored,
580
+ aaPercentage: result.aaPercentage
578
581
  };
579
582
  logger.debug(`PASSED ${sanitizedName}`);
580
583
  this.comparisons.push(comparison);
581
584
  return comparison;
582
585
  } else {
583
586
  // Images differ
584
- let diffInfo = '';
585
- if (result.reason === 'pixel-diff') {
586
- diffInfo = ` (${result.diffPercentage.toFixed(2)}% different, ${result.diffCount} pixels)`;
587
- } else if (result.reason === 'layout-diff') {
588
- diffInfo = ' (layout difference)';
587
+ let diffInfo = ` (${result.diffPercentage.toFixed(2)}% different, ${result.diffPixels} pixels)`;
588
+
589
+ // Add cluster info to log if available
590
+ if (result.diffClusters && result.diffClusters.length > 0) {
591
+ diffInfo += `, ${result.diffClusters.length} region${result.diffClusters.length > 1 ? 's' : ''}`;
589
592
  }
590
593
  const comparison = {
591
594
  name: sanitizedName,
@@ -595,9 +598,17 @@ export class TddService {
595
598
  diff: diffImagePath,
596
599
  properties: validatedProperties,
597
600
  threshold: this.threshold,
598
- diffPercentage: result.reason === 'pixel-diff' ? result.diffPercentage : null,
599
- diffCount: result.reason === 'pixel-diff' ? result.diffCount : null,
600
- reason: result.reason
601
+ diffPercentage: result.diffPercentage,
602
+ diffCount: result.diffPixels,
603
+ reason: 'pixel-diff',
604
+ // Honeydiff metrics
605
+ totalPixels: result.totalPixels,
606
+ aaPixelsIgnored: result.aaPixelsIgnored,
607
+ aaPercentage: result.aaPercentage,
608
+ boundingBox: result.boundingBox,
609
+ heightDiff: result.heightDiff,
610
+ intensityStats: result.intensityStats,
611
+ diffClusters: result.diffClusters
601
612
  };
602
613
  logger.warn(`❌ ${colors.red('FAILED')} ${sanitizedName} - differences detected${diffInfo}`);
603
614
  logger.info(` Diff saved to: ${diffImagePath}`);
package/docs/tdd-mode.md CHANGED
@@ -7,7 +7,7 @@ TDD (Test-Driven Development) Mode enables fast local development with an intera
7
7
  TDD Mode transforms your visual testing workflow with:
8
8
 
9
9
  - **Interactive Dashboard** - Real-time visual feedback as tests run
10
- - **Local Comparison** - Compares screenshots on your machine using `odiff`
10
+ - **Local Comparison** - Compares screenshots on your machine using `honeydiff`
11
11
  - **Live Updates** - See comparisons instantly in the browser
12
12
  - **Baseline Management** - Accept/reject changes directly from the UI
13
13
  - **Fast Feedback** - No network uploads during development
@@ -90,7 +90,7 @@ TDD Mode provides two workflows:
90
90
  ### Single-Shot Workflow
91
91
 
92
92
  1. **Run tests** - `vizzly tdd run "npm test"` executes once
93
- 2. **Compares locally** - Uses `odiff` for pixel-perfect comparison
93
+ 2. **Compares locally** - Uses `honeydiff` for high-performance comparison
94
94
  3. **Generates report** - Creates HTML report with visual comparisons
95
95
  4. **Exit with status** - Fails if differences exceed threshold
96
96
 
@@ -452,14 +452,14 @@ rm -rf .vizzly/baselines/
452
452
  npx vizzly tdd run "npm test"
453
453
  ```
454
454
 
455
- ### Odiff Not Found
455
+ ### Honeydiff Not Found
456
456
  ```
457
- Error: odiff binary not found
457
+ Error: Cannot find module '@vizzly-testing/honeydiff'
458
458
  ```
459
459
 
460
- **Solution**: The `odiff-bin` package should be installed automatically. Try:
460
+ **Solution**: The `@vizzly-testing/honeydiff` package should be installed automatically. Try:
461
461
  ```bash
462
- npm install odiff-bin
462
+ npm install @vizzly-testing/honeydiff
463
463
  ```
464
464
 
465
465
  ## Best Practices
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly-testing/cli",
3
- "version": "0.11.2",
3
+ "version": "0.12.0",
4
4
  "description": "Visual review platform for UI developers and designers",
5
5
  "keywords": [
6
6
  "visual-testing",
@@ -79,12 +79,12 @@
79
79
  "registry": "https://registry.npmjs.org/"
80
80
  },
81
81
  "dependencies": {
82
+ "@vizzly-testing/honeydiff": "^0.1.0",
82
83
  "commander": "^14.0.0",
83
84
  "cosmiconfig": "^9.0.0",
84
85
  "dotenv": "^17.2.1",
85
86
  "form-data": "^4.0.0",
86
87
  "glob": "^11.0.3",
87
- "odiff-bin": "^3.2.1",
88
88
  "zod": "^4.1.12"
89
89
  },
90
90
  "devDependencies": {