Skip to content

Commit 5b11a6b

Browse files
committed
♻️ Rename snapshot → screenshot for consistency
- Rename vizzlySnapshot → vizzlyScreenshot - Rename snapshot-server → screenshot-server - Rename /snapshot endpoint → /screenshot - Rename __VIZZLY_SNAPSHOT_URL__ → __VIZZLY_SCREENSHOT_URL__ - Update all docs and comments
1 parent 48e7b77 commit 5b11a6b

File tree

13 files changed

+183
-183
lines changed

13 files changed

+183
-183
lines changed

clients/ember/CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
- Initial beta release of Vizzly Ember SDK for visual testing with Testem
1515
- Custom Testem launcher using Playwright for browser control (Chromium, Firefox, WebKit)
16-
- `vizzlySnapshot()` helper for capturing screenshots in acceptance tests
16+
- `vizzlyScreenshot()` helper for capturing screenshots in acceptance tests
1717
- Automatic viewport sizing and `#ember-testing` container expansion
1818
- TDD server auto-discovery via `.vizzly/server.json`
1919
- Mobile viewport testing with customizable dimensions
2020
- Support for both TDD mode (local comparison) and cloud mode
2121

2222
### Architecture
2323

24-
The SDK uses a snapshot server pattern:
25-
- Browser tests call `vizzlySnapshot()` which sends requests to a local snapshot server
26-
- Snapshot server uses Playwright to capture screenshots
24+
The SDK uses a screenshot server pattern:
25+
- Browser tests call `vizzlyScreenshot()` which sends requests to a local screenshot server
26+
- Screenshot server uses Playwright to capture screenshots
2727
- Screenshots are forwarded to the Vizzly TDD server for comparison
2828

2929
**Full Changelog**: https://github.com/vizzly-testing/cli/commits/ember/v0.0.1-beta.0

clients/ember/README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ The `configure()` function replaces standard browser launchers (Chrome, Firefox,
3535

3636
> **Note for Ember + Vite projects**: The `cwd: 'dist'` option is required because Vite builds test files into the `dist/` directory. Without this, Testem won't find your test assets.
3737
38-
### 2. Write Tests with Snapshots
38+
### 2. Write Tests with Screenshots
3939

40-
Import `vizzlySnapshot` in your test files:
40+
Import `vizzlyScreenshot` in your test files:
4141

4242
```javascript
4343
// tests/acceptance/dashboard-test.js
4444
import { module, test } from 'qunit';
4545
import { visit } from '@ember/test-helpers';
4646
import { setupApplicationTest } from 'ember-qunit';
47-
import { vizzlySnapshot } from '@vizzly-testing/ember/test-support';
47+
import { vizzlyScreenshot } from '@vizzly-testing/ember/test-support';
4848

4949
module('Acceptance | Dashboard', function(hooks) {
5050
setupApplicationTest(hooks);
@@ -53,7 +53,7 @@ module('Acceptance | Dashboard', function(hooks) {
5353
await visit('/dashboard');
5454

5555
// Capture screenshot
56-
await vizzlySnapshot('dashboard-empty');
56+
await vizzlyScreenshot('dashboard-empty');
5757

5858
assert.dom('[data-test-empty-state]').exists();
5959
});
@@ -63,7 +63,7 @@ module('Acceptance | Dashboard', function(hooks) {
6363
await visit('/dashboard');
6464

6565
// Capture specific element
66-
await vizzlySnapshot('dashboard-table', {
66+
await vizzlyScreenshot('dashboard-table', {
6767
selector: '[data-test-data-table]'
6868
});
6969

@@ -142,29 +142,29 @@ The second argument accepts [Playwright browserType.launch() options](https://pl
142142
- `Firefox` → Uses Playwright Firefox
143143
- `Safari` / `WebKit` → Uses Playwright WebKit
144144

145-
### `vizzlySnapshot(name, options?)`
145+
### `vizzlyScreenshot(name, options?)`
146146

147147
Captures a screenshot and sends it to Vizzly for comparison. By default, captures just the `#ember-testing` container (your app), not the QUnit test runner UI.
148148

149149
```javascript
150-
import { vizzlySnapshot } from '@vizzly-testing/ember/test-support';
150+
import { vizzlyScreenshot } from '@vizzly-testing/ember/test-support';
151151

152152
// Basic usage - captures app at 1280x720
153-
await vizzlySnapshot('homepage');
153+
await vizzlyScreenshot('homepage');
154154

155155
// Mobile viewport
156-
await vizzlySnapshot('homepage-mobile', {
156+
await vizzlyScreenshot('homepage-mobile', {
157157
width: 375,
158158
height: 667
159159
});
160160

161161
// Capture specific element within the app
162-
await vizzlySnapshot('login-form', {
162+
await vizzlyScreenshot('login-form', {
163163
selector: '[data-test-login-form]'
164164
});
165165

166166
// Full options
167-
await vizzlySnapshot('screenshot-name', {
167+
await vizzlyScreenshot('screenshot-name', {
168168
// Viewport dimensions (default: 1280x720)
169169
width: 1280,
170170
height: 720,
@@ -198,7 +198,7 @@ await vizzlySnapshot('screenshot-name', {
198198
| `selector` | string | null | CSS selector to capture specific element |
199199
| `scope` | string | 'app' | What to capture: `'app'` (just #ember-testing), `'container'`, or `'page'` (full page including QUnit) |
200200
| `fullPage` | boolean | false | Capture full scrollable content |
201-
| `properties` | object | {} | Custom metadata attached to the snapshot |
201+
| `properties` | object | {} | Custom metadata attached to the screenshot |
202202
| `failOnDiff` | boolean | null | Fail the test when visual diff is detected. `null` uses the `--fail-on-diff` CLI flag. |
203203

204204
The function automatically:
@@ -214,7 +214,7 @@ Check if Vizzly is available in the current test environment.
214214
import { isVizzlyAvailable } from '@vizzly-testing/ember/test-support';
215215

216216
if (isVizzlyAvailable()) {
217-
await vizzlySnapshot('conditional-snapshot');
217+
await vizzlyScreenshot('conditional-screenshot');
218218
}
219219
```
220220

@@ -239,7 +239,7 @@ npx playwright install webkit
239239
1. **Testem Configuration**: The `configure()` wrapper replaces standard browser launchers with custom Vizzly launchers
240240
2. **Custom Launcher**: When Testem starts, it spawns `vizzly-testem-launcher` which uses Playwright
241241
3. **Playwright Integration**: The launcher uses Playwright to control the browser and capture screenshots
242-
4. **Snapshot Server**: A local HTTP server receives screenshot requests from test code
242+
4. **Screenshot Server**: A local HTTP server receives screenshot requests from test code
243243
5. **Vizzly Integration**: Screenshots are forwarded to the Vizzly TDD server for comparison
244244

245245
## CI/CD
@@ -268,15 +268,15 @@ By default, visual differences don't fail tests (similar to Percy). To fail test
268268
# Via CLI flag
269269
vizzly tdd start --fail-on-diff
270270

271-
# Or per-snapshot in your test
272-
await vizzlySnapshot('critical-ui', { failOnDiff: true });
271+
# Or per-screenshot in your test
272+
await vizzlyScreenshot('critical-ui', { failOnDiff: true });
273273
```
274274
275-
The priority order is: per-snapshot option > `--fail-on-diff` CLI flag > default (no failure).
275+
The priority order is: per-screenshot option > `--fail-on-diff` CLI flag > default (no failure).
276276

277277
## Troubleshooting
278278

279-
### "No snapshot server available"
279+
### "No screenshot server available"
280280

281281
Tests must be run through Testem with the Vizzly-configured launchers. Ensure:
282282
- `testem.js` uses `configure()` wrapper

clients/ember/bin/vizzly-testem-launcher.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import { closeBrowser, launchBrowser } from '../src/launcher/browser.js';
2323
import {
2424
getServerInfo,
2525
setPage,
26-
startSnapshotServer,
27-
stopSnapshotServer,
28-
} from '../src/launcher/snapshot-server.js';
26+
startScreenshotServer,
27+
stopScreenshotServer,
28+
} from '../src/launcher/screenshot-server.js';
2929

3030
// Parse arguments - format: vizzly-testem-launcher <browser> <url>
3131
// Testem appends the URL as the last argument
@@ -56,7 +56,7 @@ if (existsSync(configPath)) {
5656
}
5757

5858
let browserInstance = null;
59-
let snapshotServer = null;
59+
let screenshotServer = null;
6060
let isShuttingDown = false;
6161

6262
/**
@@ -75,8 +75,8 @@ async function cleanup() {
7575
}
7676

7777
try {
78-
if (snapshotServer) {
79-
await stopSnapshotServer(snapshotServer);
78+
if (screenshotServer) {
79+
await stopScreenshotServer(screenshotServer);
8080
}
8181
} catch {
8282
// Ignore cleanup errors
@@ -90,9 +90,9 @@ async function cleanup() {
9090
*/
9191
async function main() {
9292
try {
93-
// 1. Start snapshot server first (this also discovers the TDD server and caches its config)
94-
snapshotServer = await startSnapshotServer();
95-
let snapshotUrl = `http://127.0.0.1:${snapshotServer.port}`;
93+
// 1. Start screenshot server first (this also discovers the TDD server and caches its config)
94+
screenshotServer = await startScreenshotServer();
95+
let screenshotUrl = `http://127.0.0.1:${screenshotServer.port}`;
9696

9797
// 2. Determine failOnDiff: env var > server.json > default (false)
9898
let failOnDiff = false;
@@ -107,7 +107,7 @@ async function main() {
107107

108108
// 3. Launch browser with Playwright
109109
browserInstance = await launchBrowser(browserType, testUrl, {
110-
snapshotUrl,
110+
screenshotUrl,
111111
failOnDiff,
112112
playwrightOptions,
113113
onPageCreated: page => {
@@ -165,8 +165,8 @@ async function main() {
165165
} catch (error) {
166166
console.error('[vizzly-testem-launcher] Failed to start:', error.message);
167167

168-
if (snapshotServer) {
169-
await stopSnapshotServer(snapshotServer).catch(() => {});
168+
if (screenshotServer) {
169+
await stopScreenshotServer(screenshotServer).catch(() => {});
170170
}
171171

172172
process.exit(1);

clients/ember/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vizzly-testing/ember",
3-
"version": "0.0.1-beta.3",
3+
"version": "0.0.1-beta.4",
44
"description": "Visual testing SDK for Ember.js projects using Testem",
55
"keywords": [
66
"vizzly",

clients/ember/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
*
1919
* @example
2020
* // tests/acceptance/my-test.js
21-
* import { vizzlySnapshot } from '@vizzly-testing/ember/test-support';
21+
* import { vizzlyScreenshot } from '@vizzly-testing/ember/test-support';
2222
*
2323
* test('renders correctly', async function(assert) {
2424
* await visit('/');
25-
* await vizzlySnapshot('homepage');
25+
* await vizzlyScreenshot('homepage');
2626
* assert.ok(true);
2727
* });
2828
*/

clients/ember/src/launcher/browser.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Playwright browser lifecycle management
33
*
44
* Handles launching, configuring, and closing browsers via Playwright-core.
5-
* Injects the snapshot server URL into page context for test code access.
5+
* Injects the screenshot server URL into page context for test code access.
66
*
77
* @module @vizzly-testing/ember/launcher/browser
88
*/
@@ -59,15 +59,15 @@ function getDefaultChromiumArgs() {
5959
* @param {string} browserType - Browser type: chromium, firefox, webkit
6060
* @param {string} testUrl - URL to navigate to (provided by Testem)
6161
* @param {Object} options - Launch options
62-
* @param {string} options.snapshotUrl - URL of the snapshot HTTP server
62+
* @param {string} options.screenshotUrl - URL of the screenshot HTTP server
6363
* @param {boolean} [options.failOnDiff] - Whether tests should fail on visual diffs
6464
* @param {Object} [options.playwrightOptions] - Playwright launch options (headless, slowMo, timeout, etc.)
6565
* @param {Function} [options.onPageCreated] - Callback when page is created (before navigation)
6666
* @returns {Promise<Object>} Browser instance with page reference
6767
*/
6868
export async function launchBrowser(browserType, testUrl, options = {}) {
6969
let {
70-
snapshotUrl,
70+
screenshotUrl,
7171
failOnDiff,
7272
playwrightOptions = {},
7373
onPageCreated,
@@ -106,11 +106,11 @@ export async function launchBrowser(browserType, testUrl, options = {}) {
106106

107107
// Inject Vizzly config into page context BEFORE navigation
108108
await page.addInitScript(
109-
({ snapshotUrl, failOnDiff }) => {
110-
window.__VIZZLY_SNAPSHOT_URL__ = snapshotUrl;
109+
({ screenshotUrl, failOnDiff }) => {
110+
window.__VIZZLY_SCREENSHOT_URL__ = screenshotUrl;
111111
window.__VIZZLY_FAIL_ON_DIFF__ = failOnDiff;
112112
},
113-
{ snapshotUrl, failOnDiff }
113+
{ screenshotUrl, failOnDiff }
114114
);
115115

116116
// Call onPageCreated callback BEFORE navigation

clients/ember/src/launcher/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export { closeBrowser, launchBrowser } from './browser.js';
88
export {
99
getPage,
1010
setPage,
11-
startSnapshotServer,
12-
stopSnapshotServer,
13-
} from './snapshot-server.js';
11+
startScreenshotServer,
12+
stopScreenshotServer,
13+
} from './screenshot-server.js';

clients/ember/src/launcher/snapshot-server.js renamed to clients/ember/src/launcher/screenshot-server.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* HTTP server for receiving snapshot requests from browser context
2+
* HTTP server for receiving screenshot requests from browser context
33
*
44
* This server receives POST requests from test code running in the browser,
55
* captures screenshots via Playwright, and forwards them to the Vizzly TDD server.
66
*
7-
* @module @vizzly-testing/ember/launcher/snapshot-server
7+
* @module @vizzly-testing/ember/launcher/screenshot-server
88
*/
99

1010
import { existsSync, readFileSync } from 'node:fs';
@@ -186,11 +186,11 @@ function httpPost(url, data) {
186186
}
187187

188188
/**
189-
* Handle incoming snapshot request
189+
* Handle incoming screenshot request
190190
* @param {Object} req - HTTP request
191191
* @param {Object} res - HTTP response
192192
*/
193-
async function handleSnapshot(req, res) {
193+
async function handleScreenshot(req, res) {
194194
let body = '';
195195

196196
req.on('data', chunk => {
@@ -253,10 +253,10 @@ async function handleSnapshot(req, res) {
253253
}
254254

255255
/**
256-
* Start the snapshot HTTP server
256+
* Start the screenshot HTTP server
257257
* @returns {Promise<Object>} Server info with port
258258
*/
259-
export async function startSnapshotServer() {
259+
export async function startScreenshotServer() {
260260
return new Promise((resolve, reject) => {
261261
let server = createServer(async (req, res) => {
262262
// CORS headers for browser requests
@@ -272,8 +272,8 @@ export async function startSnapshotServer() {
272272
return;
273273
}
274274

275-
if (req.method === 'POST' && req.url === '/snapshot') {
276-
await handleSnapshot(req, res);
275+
if (req.method === 'POST' && req.url === '/screenshot') {
276+
await handleScreenshot(req, res);
277277
return;
278278
}
279279

@@ -298,11 +298,11 @@ export async function startSnapshotServer() {
298298
}
299299

300300
/**
301-
* Stop the snapshot server
302-
* @param {Object} serverInfo - Server info returned by startSnapshotServer
301+
* Stop the screenshot server
302+
* @param {Object} serverInfo - Server info returned by startScreenshotServer
303303
* @returns {Promise<void>}
304304
*/
305-
export async function stopSnapshotServer(serverInfo) {
305+
export async function stopScreenshotServer(serverInfo) {
306306
return new Promise(resolve => {
307307
if (serverInfo?.server) {
308308
// Force close all keep-alive connections (Node 18.2+)

0 commit comments

Comments
 (0)