@vizzly-testing/cli 0.16.3 → 0.16.4

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.
@@ -6,7 +6,7 @@
6
6
  import { createHttpServer } from '../server/http-server.js';
7
7
  import { createTddHandler } from '../server/handlers/tdd-handler.js';
8
8
  import { createApiHandler } from '../server/handlers/api-handler.js';
9
- import { writeFileSync, mkdirSync } from 'fs';
9
+ import { writeFileSync, mkdirSync, unlinkSync, existsSync } from 'fs';
10
10
  import { join } from 'path';
11
11
  export class ServerManager {
12
12
  constructor(config, options = {}) {
@@ -85,6 +85,16 @@ export class ServerManager {
85
85
  // Don't throw - cleanup errors shouldn't fail the stop process
86
86
  }
87
87
  }
88
+
89
+ // Clean up server.json so the client SDK doesn't try to connect to a dead server
90
+ try {
91
+ let serverFile = join(process.cwd(), '.vizzly', 'server.json');
92
+ if (existsSync(serverFile)) {
93
+ unlinkSync(serverFile);
94
+ }
95
+ } catch {
96
+ // Non-fatal - cleanup errors shouldn't fail the stop process
97
+ }
88
98
  }
89
99
 
90
100
  // Expose server interface for compatibility
@@ -94,4 +104,13 @@ export class ServerManager {
94
104
  finishBuild: buildId => this.httpServer?.finishBuild?.(buildId)
95
105
  };
96
106
  }
107
+
108
+ /**
109
+ * Get TDD results (comparisons, screenshot count, etc.)
110
+ * Only available in TDD mode after tests have run
111
+ */
112
+ async getTddResults() {
113
+ if (!this.tddMode || !this.handler?.getResults) return null;
114
+ return await this.handler.getResults();
115
+ }
97
116
  }
@@ -112,8 +112,25 @@ export class TestRunner extends EventEmitter {
112
112
  // Error in setup phase
113
113
  testError = error;
114
114
  testSuccess = false;
115
- } finally {
116
- // Always finalize the build and stop the server
115
+ }
116
+
117
+ // Get TDD results before stopping the server (comparisons, screenshot count)
118
+ let tddResults = null;
119
+ if (tdd) {
120
+ try {
121
+ tddResults = await this.serverManager.getTddResults();
122
+ if (tddResults) {
123
+ screenshotCount = tddResults.total || 0;
124
+ }
125
+ } catch (tddError) {
126
+ output.debug('tdd', 'failed to get results', {
127
+ error: tddError.message
128
+ });
129
+ }
130
+ }
131
+
132
+ // Always finalize the build and stop the server (cleanup phase)
133
+ try {
117
134
  const executionTime = Date.now() - startTime;
118
135
  if (buildId) {
119
136
  try {
@@ -127,6 +144,8 @@ export class TestRunner extends EventEmitter {
127
144
  if (!tdd && this.serverManager.server?.getScreenshotCount) {
128
145
  screenshotCount = this.serverManager.server.getScreenshotCount(buildId) || 0;
129
146
  }
147
+ } finally {
148
+ // Always stop the server, even if finalization fails
130
149
  try {
131
150
  await this.serverManager.stop();
132
151
  } catch (stopError) {
@@ -144,7 +163,9 @@ export class TestRunner extends EventEmitter {
144
163
  url: buildUrl,
145
164
  testsPassed: testSuccess ? 1 : 0,
146
165
  testsFailed: testSuccess ? 0 : 1,
147
- screenshotsCaptured: screenshotCount
166
+ screenshotsCaptured: screenshotCount,
167
+ comparisons: tddResults?.comparisons || null,
168
+ failed: (tddResults?.failed || 0) > 0
148
169
  };
149
170
  }
150
171
  async createBuild(options, tdd) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly-testing/cli",
3
- "version": "0.16.3",
3
+ "version": "0.16.4",
4
4
  "description": "Visual review platform for UI developers and designers",
5
5
  "keywords": [
6
6
  "visual-testing",