@ericblade/quagga2 1.12.1 → 1.13.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.
@@ -0,0 +1,718 @@
1
+ # Playwright Migration Analysis
2
+
3
+ ## Executive Summary
4
+
5
+ This document analyzes the feasibility and requirements for migrating from Cypress to Playwright for end-to-end testing in Quagga2. While Playwright offers better community support and modern features, the migration would require moderate effort due to API differences and test structure changes.
6
+
7
+ **Recommendation**: The Cypress upgrade to v15.8.1 addresses the immediate security concerns. Consider Playwright migration as a future enhancement when undertaking a broader modernization effort (e.g., Webpack 5 migration).
8
+
9
+ ---
10
+
11
+ ## Current State
12
+
13
+ ### Cypress Setup (After Upgrade)
14
+ - **Cypress**: v15.8.1 (latest)
15
+ - **@cypress/code-coverage**: v3.14.7
16
+ - **@cypress/webpack-preprocessor**: v6.0.4 (pinned to v6 for Webpack 4 compatibility)
17
+ - **Test files**: 5 spec files (~269 lines of test code)
18
+ - **Configuration**: `cypress.config.ts` with custom plugins
19
+
20
+ ### Test Coverage
21
+ 1. **Browser-specific tests** (`browser.cy.ts`): Tests that import source modules directly
22
+ 2. **Universal tests** (`universal.cy.ts`): Tests that run in both browser and Node.js
23
+ 3. **Integration tests** (`integration.cy.ts`): Full integration test suite
24
+ 4. **E2E example tests** (`examples.cy.ts`): Tests for example HTML pages
25
+ 5. **Bundle tests** (`browser-bundle.cy.ts`): Validates built `dist/quagga.min.js`
26
+
27
+ ### Key Cypress Features in Use
28
+ - Custom webpack preprocessor for TypeScript/Babel compilation
29
+ - File manipulation tasks (`cy.task()`)
30
+ - Window object access for Quagga API testing
31
+ - Custom commands and promise handling
32
+ - Code coverage integration (currently commented out)
33
+
34
+ ---
35
+
36
+ ## Playwright Overview
37
+
38
+ ### Benefits of Playwright
39
+
40
+ 1. **Better Community Support**
41
+ - Maintained by Microsoft, actively developed
42
+ - Large and growing community
43
+ - More frequent updates and better documentation
44
+
45
+ 2. **Modern Testing Features**
46
+ - Auto-waiting and better stability
47
+ - Built-in TypeScript support (no preprocessor needed)
48
+ - Parallel test execution by default
49
+ - Better debugging tools (trace viewer, inspector)
50
+ - API testing capabilities
51
+
52
+ 3. **Cross-Browser Support**
53
+ - Chromium, Firefox, WebKit (Safari) engines
54
+ - Better mobile browser emulation
55
+ - Consistent behavior across browsers
56
+
57
+ 4. **Performance**
58
+ - Faster test execution
59
+ - Better resource management
60
+ - Built-in test retry logic
61
+
62
+ 5. **Developer Experience**
63
+ - Better error messages
64
+ - Built-in test generator (codegen)
65
+ - VS Code extension with debugging
66
+ - Better CI/CD integration
67
+
68
+ ### Playwright Versions
69
+ - **Current**: v1.57.0 (as of 2026-01-05)
70
+ - **@playwright/test**: v1.57.0 (test runner)
71
+ - **Package size**: Similar to Cypress (~50-60 MB installed)
72
+
73
+ ---
74
+
75
+ ## Migration Effort Analysis
76
+
77
+ ### High-Level Comparison
78
+
79
+ | Aspect | Cypress | Playwright | Migration Effort |
80
+ |--------|---------|------------|------------------|
81
+ | Test runner | Mocha-based | Jest-like | Low - Similar syntax |
82
+ | Browser control | `cy.*` commands | `page.*` actions | Medium - API translation needed |
83
+ | Assertions | Chai | Expect | Low - Similar concepts |
84
+ | TypeScript | Requires preprocessor | Built-in | Low - Simplifies setup |
85
+ | Window access | `cy.window()` | `page.evaluate()` | Medium - Pattern change |
86
+ | File tasks | `cy.task()` | Node.js APIs | Low - Direct access |
87
+ | Async handling | Cypress Promise | Standard Promise | Medium - Different patterns |
88
+
89
+ ### Estimated Effort
90
+
91
+ **Time Investment**: 8-16 hours
92
+
93
+ - **Setup and Configuration**: 2-3 hours
94
+ - **Test Migration**: 4-8 hours (depends on complexity)
95
+ - **Debugging and Refinement**: 2-3 hours
96
+ - **Documentation**: 1-2 hours
97
+
98
+ **Complexity**: Medium
99
+
100
+ ---
101
+
102
+ ## Technical Migration Path
103
+
104
+ ### 1. Dependencies
105
+
106
+ **Remove:**
107
+ ```json
108
+ "cypress": "^15.8.1",
109
+ "@cypress/webpack-preprocessor": "^6.0.4",
110
+ "@cypress/code-coverage": "^3.14.7"
111
+ ```
112
+
113
+ **Add:**
114
+ ```json
115
+ "@playwright/test": "^1.57.0"
116
+ ```
117
+
118
+ **Savings**: ~20-30 MB in `node_modules` size (Playwright is slightly smaller)
119
+
120
+ ### 2. Configuration
121
+
122
+ **Create `playwright.config.ts`:**
123
+ ```typescript
124
+ import { defineConfig, devices } from '@playwright/test';
125
+
126
+ export default defineConfig({
127
+ testDir: './tests/e2e',
128
+ fullyParallel: true,
129
+ forbidOnly: !!process.env.CI,
130
+ retries: process.env.CI ? 2 : 0,
131
+ workers: process.env.CI ? 1 : undefined,
132
+ reporter: 'html',
133
+ use: {
134
+ baseURL: 'http://localhost:8080',
135
+ trace: 'on-first-retry',
136
+ },
137
+ projects: [
138
+ {
139
+ name: 'chromium',
140
+ use: { ...devices['Desktop Chrome'] },
141
+ },
142
+ // Optional: Add Firefox, WebKit
143
+ ],
144
+ webServer: {
145
+ command: 'npm run server:examples',
146
+ url: 'http://localhost:8080',
147
+ reuseExistingServer: !process.env.CI,
148
+ },
149
+ });
150
+ ```
151
+
152
+ **Remove:**
153
+ - `cypress.config.ts`
154
+ - `cypress/plugins/index.js`
155
+ - `cypress/support/` directory
156
+
157
+ ### 3. Test Migration Examples
158
+
159
+ #### Example 1: Browser Bundle Test
160
+
161
+ **Cypress** (`cypress/e2e/browser-bundle.cy.ts`):
162
+ ```typescript
163
+ describe('Browser Bundle - decodeSingle', () => {
164
+ before(() => {
165
+ const html = `...`;
166
+ cy.writeFile('cypress/fixtures/bundle-test.html', html);
167
+ });
168
+
169
+ it('should decode a Code 128 barcode', () => {
170
+ cy.visit('/cypress/fixtures/bundle-test.html');
171
+ cy.window().should('have.property', 'Quagga');
172
+
173
+ cy.window().then((win) => {
174
+ return new Cypress.Promise((resolve, reject) => {
175
+ win.Quagga.decodeSingle({ ... }, (result) => {
176
+ expect(result.codeResult.code).to.be.a('string');
177
+ resolve(result);
178
+ });
179
+ });
180
+ });
181
+ });
182
+ });
183
+ ```
184
+
185
+ **Playwright** (`tests/e2e/browser-bundle.spec.ts`):
186
+ ```typescript
187
+ import { test, expect } from '@playwright/test';
188
+ import fs from 'fs';
189
+ import path from 'path';
190
+
191
+ test.describe('Browser Bundle - decodeSingle', () => {
192
+ test.beforeAll(() => {
193
+ const html = `...`;
194
+ fs.writeFileSync('tests/fixtures/bundle-test.html', html);
195
+ });
196
+
197
+ test('should decode a Code 128 barcode', async ({ page }) => {
198
+ await page.goto('/tests/fixtures/bundle-test.html');
199
+
200
+ // Check Quagga is available
201
+ const hasQuagga = await page.evaluate(() => 'Quagga' in window);
202
+ expect(hasQuagga).toBe(true);
203
+
204
+ // Call decodeSingle and get result
205
+ const result = await page.evaluate(() => {
206
+ return new Promise((resolve, reject) => {
207
+ window.Quagga.decodeSingle({
208
+ src: '/test/fixtures/code_128/image-001.jpg',
209
+ numOfWorkers: 0,
210
+ decoder: { readers: ['code_128_reader'] }
211
+ }, (result) => {
212
+ if (result?.codeResult) {
213
+ resolve(result.codeResult);
214
+ } else {
215
+ reject(new Error('Failed to decode'));
216
+ }
217
+ });
218
+ });
219
+ });
220
+
221
+ expect(result.code).toBeTruthy();
222
+ expect(typeof result.code).toBe('string');
223
+ });
224
+
225
+ test.afterAll(() => {
226
+ fs.unlinkSync('tests/fixtures/bundle-test.html');
227
+ });
228
+ });
229
+ ```
230
+
231
+ #### Example 2: E2E Example Page Test
232
+
233
+ **Cypress** (`cypress/e2e/examples.cy.ts`):
234
+ ```typescript
235
+ describe('Example Pages E2E', () => {
236
+ beforeEach(() => {
237
+ cy.visit('http://localhost:8080/live_w_locator.html');
238
+ });
239
+
240
+ it('should load the page successfully', () => {
241
+ cy.contains('h1', 'QuaggaJS').should('be.visible');
242
+ });
243
+
244
+ it('should have a camera dropdown', () => {
245
+ cy.get('select#deviceSelection').should('exist');
246
+ });
247
+ });
248
+ ```
249
+
250
+ **Playwright** (`tests/e2e/examples.spec.ts`):
251
+ ```typescript
252
+ import { test, expect } from '@playwright/test';
253
+
254
+ test.describe('Example Pages E2E', () => {
255
+ test.beforeEach(async ({ page }) => {
256
+ await page.goto('/live_w_locator.html');
257
+ });
258
+
259
+ test('should load the page successfully', async ({ page }) => {
260
+ await expect(page.locator('h1:has-text("QuaggaJS")')).toBeVisible();
261
+ });
262
+
263
+ test('should have a camera dropdown', async ({ page }) => {
264
+ await expect(page.locator('select#deviceSelection')).toBeVisible();
265
+ });
266
+ });
267
+ ```
268
+
269
+ ### 4. API Translation Guide
270
+
271
+ | Cypress | Playwright | Notes |
272
+ |---------|------------|-------|
273
+ | `cy.visit(url)` | `page.goto(url)` | Await required |
274
+ | `cy.get(selector)` | `page.locator(selector)` | Lazy evaluation |
275
+ | `cy.contains(text)` | `page.locator('text=...')` | Different syntax |
276
+ | `cy.window()` | `page.evaluate()` | Execute in browser context |
277
+ | `cy.task()` | Direct Node.js | No need for tasks |
278
+ | `cy.writeFile()` | `fs.writeFileSync()` | Direct file access |
279
+ | `cy.wait(ms)` | `page.waitForTimeout(ms)` | Use sparingly |
280
+ | `.should('be.visible')` | `await expect().toBeVisible()` | Async assertions |
281
+ | `.should('have.property')` | `await expect().toHaveProperty()` | Different API |
282
+ | `cy.wrap(promise)` | `await promise` | Standard async/await |
283
+
284
+ ### 5. Script Updates
285
+
286
+ **Update `package.json` scripts:**
287
+
288
+ ```json
289
+ {
290
+ "scripts": {
291
+ "test:e2e": "playwright test",
292
+ "test:e2e:ui": "playwright test --ui",
293
+ "test:e2e:debug": "playwright test --debug",
294
+ "test:e2e:headed": "playwright test --headed",
295
+ "test:browser-bundle": "npm run build:prod && playwright test tests/e2e/browser-bundle.spec.ts",
296
+ "test:browser-all": "playwright test",
297
+ "playwright:codegen": "playwright codegen http://localhost:8080"
298
+ }
299
+ }
300
+ ```
301
+
302
+ **Remove Cypress scripts:**
303
+ - `cypress:open`
304
+ - `cypress:open:e2e`
305
+ - `cypress:run`
306
+ - `cypress:run:e2e`
307
+
308
+ ---
309
+
310
+ ## Challenges and Considerations
311
+
312
+ ### 1. Webpack Preprocessor Dependency
313
+
314
+ **Challenge**: Cypress currently uses `@cypress/webpack-preprocessor` to compile TypeScript tests.
315
+
316
+ **Playwright Solution**: Built-in TypeScript support - no preprocessor needed. This actually **simplifies** the setup.
317
+
318
+ ### 2. Custom Tasks
319
+
320
+ **Challenge**: Cypress uses custom tasks (`cy.task()`) for file operations.
321
+
322
+ **Playwright Solution**: Direct Node.js API access in tests. Tests run in Node.js environment with full access to `fs`, `path`, etc.
323
+
324
+ **Impact**: Positive - Simpler code, no custom plugin needed.
325
+
326
+ ### 3. Window Object Access
327
+
328
+ **Challenge**: Many tests access `window.Quagga` for API testing.
329
+
330
+ **Playwright Solution**: Use `page.evaluate()` to run code in browser context.
331
+
332
+ **Impact**: Moderate - Requires refactoring but provides more explicit separation.
333
+
334
+ ### 4. Promise Handling
335
+
336
+ **Challenge**: Cypress uses custom promise chain (`Cypress.Promise`).
337
+
338
+ **Playwright Solution**: Standard async/await with native Promises.
339
+
340
+ **Impact**: Moderate - Cleaner code but requires rewriting promise chains.
341
+
342
+ ### 5. Code Coverage
343
+
344
+ **Challenge**: Currently using `@cypress/code-coverage` (commented out in code).
345
+
346
+ **Playwright Solution**: Can integrate with `@playwright/test` coverage via V8 coverage or Istanbul.
347
+
348
+ **Resources**: https://playwright.dev/docs/test-coverage
349
+
350
+ ### 6. Source Import Tests
351
+
352
+ **Challenge**: `browser.cy.ts` imports source TypeScript files directly:
353
+ ```typescript
354
+ import '../../src/analytics/test/browser/result_collector.spec.ts';
355
+ ```
356
+
357
+ **Playwright Solution**: Tests can still import source files - Playwright's test runner handles TypeScript.
358
+
359
+ **Impact**: Low - May need minor path adjustments.
360
+
361
+ ---
362
+
363
+ ## Compatibility Matrix
364
+
365
+ ### Browser Support
366
+
367
+ | Browser | Cypress 15 | Playwright 1.57 |
368
+ |---------|-----------|-----------------|
369
+ | Chrome | ✅ | ✅ |
370
+ | Firefox | ✅ | ✅ |
371
+ | Safari | ❌ (WebKit limited) | ✅ (Full WebKit) |
372
+ | Edge | ✅ | ✅ |
373
+ | Electron | ✅ | ❌ (Not primary focus) |
374
+
375
+ **Note**: Playwright's WebKit engine provides better Safari testing than Cypress.
376
+
377
+ ### Operating Systems
378
+
379
+ | OS | Cypress | Playwright |
380
+ |----|---------|------------|
381
+ | Linux | ✅ | ✅ |
382
+ | macOS | ✅ | ✅ |
383
+ | Windows | ✅ | ✅ |
384
+
385
+ ### CI/CD Integration
386
+
387
+ Both Cypress and Playwright work well in CI/CD environments:
388
+ - GitHub Actions: Excellent support for both
389
+ - Docker: Playwright has official images
390
+ - Headless mode: Both support headless testing
391
+
392
+ ---
393
+
394
+ ## Migration Checklist
395
+
396
+ ### Phase 1: Preparation
397
+ - [ ] Review all Cypress tests and document custom patterns
398
+ - [ ] Ensure all tests pass with current Cypress setup
399
+ - [ ] Backup current test suite
400
+ - [ ] Set up Playwright in a separate branch
401
+
402
+ ### Phase 2: Setup
403
+ - [ ] Install `@playwright/test`
404
+ - [ ] Create `playwright.config.ts`
405
+ - [ ] Create `tests/e2e/` directory structure
406
+ - [ ] Update `.gitignore` for Playwright artifacts
407
+
408
+ ### Phase 3: Migration
409
+ - [ ] Migrate `browser-bundle.cy.ts` → `browser-bundle.spec.ts`
410
+ - [ ] Migrate `examples.cy.ts` → `examples.spec.ts`
411
+ - [ ] Migrate `integration.cy.ts` → `integration.spec.ts`
412
+ - [ ] Migrate `browser.cy.ts` → `browser.spec.ts`
413
+ - [ ] Migrate `universal.cy.ts` → `universal.spec.ts`
414
+
415
+ ### Phase 4: Validation
416
+ - [ ] Run all Playwright tests
417
+ - [ ] Compare coverage with Cypress (if applicable)
418
+ - [ ] Test in CI/CD environment
419
+ - [ ] Performance comparison
420
+
421
+ ### Phase 5: Cleanup
422
+ - [ ] Remove Cypress dependencies
423
+ - [ ] Remove Cypress configuration files
424
+ - [ ] Update documentation
425
+ - [ ] Archive old Cypress tests
426
+
427
+ ---
428
+
429
+ ## Code Coverage Comparison
430
+
431
+ ### Cypress Code Coverage
432
+ ```json
433
+ {
434
+ "@cypress/code-coverage": "^3.14.7",
435
+ "babel-plugin-istanbul": "^7.0.1",
436
+ "nyc": "^17.1.0"
437
+ }
438
+ ```
439
+
440
+ **Setup**: Requires Istanbul instrumentation via Babel plugin.
441
+
442
+ ### Playwright Code Coverage
443
+
444
+ **Option 1: V8 Coverage (Recommended)**
445
+ ```typescript
446
+ // playwright.config.ts
447
+ export default defineConfig({
448
+ use: {
449
+ coverage: {
450
+ provider: 'v8',
451
+ reporter: ['html', 'json', 'text'],
452
+ }
453
+ }
454
+ });
455
+ ```
456
+
457
+ **Option 2: Istanbul Integration**
458
+ ```bash
459
+ npm install --save-dev @playwright/test @vitest/coverage-istanbul
460
+ ```
461
+
462
+ **Comparison**:
463
+ - Playwright: Simpler setup, built-in support
464
+ - Cypress: Requires additional Babel configuration
465
+
466
+ ---
467
+
468
+ ## Performance Comparison
469
+
470
+ ### Test Execution Speed
471
+
472
+ Based on typical web testing scenarios:
473
+
474
+ | Metric | Cypress | Playwright | Winner |
475
+ |--------|---------|------------|--------|
476
+ | Test startup | ~3-5s | ~1-2s | Playwright |
477
+ | Single test | Similar | Similar | Tie |
478
+ | Parallel tests | Limited | Native | Playwright |
479
+ | Browser launch | ~2s | ~1s | Playwright |
480
+
481
+ **Expected Improvement**: 20-30% faster test suite execution with Playwright.
482
+
483
+ ### Resource Usage
484
+
485
+ | Resource | Cypress | Playwright |
486
+ |----------|---------|------------|
487
+ | Memory | Higher (Electron) | Lower |
488
+ | CPU | Moderate | Moderate |
489
+ | Disk | ~60 MB | ~50 MB |
490
+
491
+ ---
492
+
493
+ ## Risks and Mitigation
494
+
495
+ ### Risk 1: Test Behavior Changes
496
+ **Impact**: Medium
497
+ **Probability**: Low
498
+ **Mitigation**: Extensive manual testing, side-by-side comparison
499
+
500
+ ### Risk 2: Learning Curve
501
+ **Impact**: Low
502
+ **Probability**: Medium
503
+ **Mitigation**: Playwright documentation is excellent, community support is strong
504
+
505
+ ### Risk 3: Tool-Specific Issues
506
+ **Impact**: Medium
507
+ **Probability**: Low
508
+ **Mitigation**: Playwright is mature and well-tested in production
509
+
510
+ ### Risk 4: CI/CD Integration Issues
511
+ **Impact**: Medium
512
+ **Probability**: Low
513
+ **Mitigation**: Test in CI environment early, Playwright has excellent GitHub Actions support
514
+
515
+ ---
516
+
517
+ ## Cost-Benefit Analysis
518
+
519
+ ### Benefits
520
+ 1. ✅ Better community support and active development
521
+ 2. ✅ Simpler setup (no webpack preprocessor needed)
522
+ 3. ✅ Better debugging tools
523
+ 4. ✅ Faster test execution
524
+ 5. ✅ Better Safari/WebKit testing
525
+ 6. ✅ Native TypeScript support
526
+ 7. ✅ Better CI/CD integration
527
+
528
+ ### Costs
529
+ 1. ❌ Migration effort (8-16 hours)
530
+ 2. ❌ Team learning curve
531
+ 3. ❌ Potential for subtle behavioral differences
532
+ 4. ❌ Temporary maintenance of two test frameworks during migration
533
+
534
+ ### Net Assessment
535
+ **ROI**: Positive, especially if:
536
+ - Planning other modernization efforts (e.g., Webpack 5)
537
+ - Scaling up test coverage
538
+ - Need better cross-browser testing
539
+ - Want improved CI/CD performance
540
+
541
+ ---
542
+
543
+ ## Recommended Timeline
544
+
545
+ ### Immediate (Current State)
546
+ - ✅ **Completed**: Upgrade Cypress to v15.8.1 to address security issues
547
+ - ✅ Keep current Cypress setup working
548
+
549
+ ### Short Term (1-3 months)
550
+ - **Optional**: Run Playwright in parallel with Cypress for evaluation
551
+ - Document any Cypress-specific issues encountered
552
+
553
+ ### Medium Term (3-6 months)
554
+ - Consider migration when doing Webpack 5 upgrade
555
+ - Migrate tests as part of broader modernization
556
+
557
+ ### Long Term (6-12 months)
558
+ - Evaluate test framework performance and maintainability
559
+ - Make final decision based on project needs
560
+
561
+ ---
562
+
563
+ ## Alternative Approach: Hybrid Strategy
564
+
565
+ Instead of full migration, consider:
566
+
567
+ 1. **Keep Cypress for existing tests**
568
+ - No migration effort
569
+ - Proven to work
570
+
571
+ 2. **Use Playwright for new tests**
572
+ - Gradual adoption
573
+ - Learn by doing
574
+ - Compare tools in practice
575
+
576
+ 3. **Eventual consolidation**
577
+ - After 6-12 months, evaluate which tool is better
578
+ - Migrate remaining tests to the winner
579
+
580
+ **Benefits**:
581
+ - Lower risk
582
+ - Time to learn Playwright
583
+ - Real-world comparison
584
+
585
+ **Drawbacks**:
586
+ - Maintaining two test frameworks
587
+ - Confusion about which to use
588
+ - Duplicate dependencies
589
+
590
+ ---
591
+
592
+ ## Resources
593
+
594
+ ### Playwright Documentation
595
+ - Official Docs: https://playwright.dev
596
+ - API Reference: https://playwright.dev/docs/api/class-playwright
597
+ - Migration Guide: https://playwright.dev/docs/migrating
598
+
599
+ ### Migration Tools
600
+ - Cypress to Playwright converter (community): https://github.com/vitalets/playwright-bdd
601
+ - Manual migration guide: https://playwright.dev/docs/cypress
602
+
603
+ ### Community
604
+ - Discord: https://aka.ms/playwright/discord
605
+ - GitHub: https://github.com/microsoft/playwright
606
+ - Stack Overflow: `playwright` tag
607
+
608
+ ---
609
+
610
+ ## Conclusion
611
+
612
+ **Short-term recommendation**: The Cypress upgrade to v15.8.1 successfully addresses the immediate security concerns raised in the issue. The tests are working, and the setup is stable.
613
+
614
+ **Long-term recommendation**: Playwright migration is **technically feasible** and would bring **net benefits**, but is not urgent. Consider migration when:
615
+ 1. Undertaking Webpack 5 upgrade (removing webpack-preprocessor dependency)
616
+ 2. Scaling up E2E test coverage significantly
617
+ 3. Need better Safari/cross-browser testing
618
+ 4. Team has capacity for the 8-16 hour migration effort
619
+
620
+ **Hybrid approach**: For lowest risk, introduce Playwright for new tests while keeping Cypress for existing ones, then consolidate after 6-12 months of experience.
621
+
622
+ ---
623
+
624
+ ## Version History
625
+
626
+ - **2026-01-05**: Initial analysis based on Cypress 15.8.1 upgrade
627
+ - **Author**: GitHub Copilot
628
+ - **Related Issue**: "Can we upgrade Cypress?"
629
+
630
+ ---
631
+
632
+ ## Appendix A: File Structure Comparison
633
+
634
+ ### Current Cypress Structure
635
+ ```
636
+ cypress/
637
+ ├── e2e/
638
+ │ ├── browser-bundle.cy.ts
639
+ │ ├── browser.cy.ts
640
+ │ ├── examples.cy.ts
641
+ │ ├── integration.cy.ts
642
+ │ ├── integration/
643
+ │ │ └── decoder/
644
+ │ │ └── pharmacode.cy.ts
645
+ │ └── universal.cy.ts
646
+ ├── fixtures/
647
+ ├── plugins/
648
+ │ └── index.js
649
+ └── support/
650
+ cypress.config.ts
651
+ ```
652
+
653
+ ### Proposed Playwright Structure
654
+ ```
655
+ tests/
656
+ ├── e2e/
657
+ │ ├── browser-bundle.spec.ts
658
+ │ ├── browser.spec.ts
659
+ │ ├── examples.spec.ts
660
+ │ ├── integration.spec.ts
661
+ │ ├── integration/
662
+ │ │ └── decoder/
663
+ │ │ └── pharmacode.spec.ts
664
+ │ └── universal.spec.ts
665
+ └── fixtures/
666
+ playwright.config.ts
667
+ ```
668
+
669
+ ---
670
+
671
+ ## Appendix B: Sample Migration Script
672
+
673
+ For automated migration assistance:
674
+
675
+ ```bash
676
+ #!/bin/bash
677
+ # migrate-cypress-to-playwright.sh
678
+
679
+ # Create new test directory
680
+ mkdir -p tests/e2e
681
+
682
+ # Copy and rename test files
683
+ for file in cypress/e2e/**/*.cy.ts; do
684
+ newfile="${file//cypress\/e2e/tests\/e2e}"
685
+ newfile="${newfile//.cy.ts/.spec.ts}"
686
+ mkdir -p "$(dirname "$newfile")"
687
+
688
+ # Basic transformations
689
+ sed -e 's/describe/test.describe/g' \
690
+ -e 's/it(/test(/g' \
691
+ -e 's/beforeEach/test.beforeEach/g' \
692
+ -e 's/afterEach/test.afterEach/g' \
693
+ -e "s/import.*'cypress'/import { test, expect } from '@playwright\/test'/g" \
694
+ "$file" > "$newfile"
695
+
696
+ echo "Migrated: $file -> $newfile"
697
+ done
698
+
699
+ echo "Migration complete! Manual review and fixes required."
700
+ ```
701
+
702
+ **Note**: This script provides a starting point but manual review and fixes are **required**.
703
+
704
+ ---
705
+
706
+ ## Appendix C: Testing Checklist
707
+
708
+ After migration, verify:
709
+
710
+ - [ ] All tests pass
711
+ - [ ] Visual regression (if applicable)
712
+ - [ ] Camera access tests work
713
+ - [ ] File upload/download tests work
714
+ - [ ] Browser console access works
715
+ - [ ] Performance is acceptable
716
+ - [ ] CI/CD pipeline works
717
+ - [ ] Documentation is updated
718
+ - [ ] Team is trained on new tools