Skip to content

Commit e8f7e34

Browse files
author
greweb
committed
TypeScript migration
1 parent 4fd5b3a commit e8f7e34

21 files changed

+268
-202
lines changed

example/e2e/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,52 @@ This removes duplicate `libfbjni.so` files from `react-native-gesture-handler` b
130130
### Validation
131131

132132
- `SnapshotMatcher` - Image comparison with tolerance
133+
- **Platform-specific snapshots** - Separate reference images for iOS/Android
133134
- Platform-specific timeouts (`getPlatformTimeout`)
134135
- Auto-capture detection and handling
135136

137+
## Snapshot Testing
138+
139+
### Platform-Specific References
140+
141+
Screenshot references are **separated by platform** to account for rendering differences:
142+
143+
```
144+
snapshots/
145+
├── reference/
146+
│ ├── ios/ # iOS reference images
147+
│ │ ├── basic_viewshot.png
148+
│ │ ├── fullscreen_viewshot.png
149+
│ │ └── ...
150+
│ └── android/ # Android reference images
151+
│ ├── basic_viewshot.png
152+
│ └── ...
153+
└── output/ # Test outputs (gitignored)
154+
├── ios/
155+
└── android/
156+
```
157+
158+
**Why separate?** iOS and Android render differently:
159+
160+
- Different fonts and antialiasing
161+
- Different native components
162+
- Different screen densities
163+
164+
### Updating Reference Images
165+
166+
To regenerate reference images for a platform:
167+
168+
```bash
169+
# iOS
170+
cd example
171+
UPDATE_SNAPSHOTS=true npm run test:e2e:ios
172+
173+
# Android (when working)
174+
UPDATE_SNAPSHOTS=true npm run test:e2e:android
175+
```
176+
177+
This will save new screenshots to `snapshots/reference/{platform}/`.
178+
136179
## CI Integration
137180

138181
iOS tests run automatically in GitHub Actions:

example/e2e/helpers/snapshot-matcher.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@ const path = require('path');
33

44
/**
55
* Helper to validate captured screenshots against reference snapshots
6+
* Snapshots are platform-specific (iOS vs Android) to account for rendering differences
67
*/
78
class SnapshotMatcher {
89
constructor() {
9-
this.referenceDir = path.join(__dirname, '../snapshots/reference');
10-
this.outputDir = path.join(__dirname, '../snapshots/output');
10+
// Get platform from Detox device
11+
const platform = device.getPlatform(); // 'ios' or 'android'
12+
13+
// Platform-specific directories to handle rendering differences
14+
this.referenceDir = path.join(
15+
__dirname,
16+
'../snapshots/reference',
17+
platform,
18+
);
19+
this.outputDir = path.join(__dirname, '../snapshots/output', platform);
1120

1221
// Ensure directories exist
1322
if (!fs.existsSync(this.referenceDir)) {
@@ -16,6 +25,10 @@ class SnapshotMatcher {
1625
if (!fs.existsSync(this.outputDir)) {
1726
fs.mkdirSync(this.outputDir, { recursive: true });
1827
}
28+
29+
console.log(`📸 SnapshotMatcher initialized for ${platform}`);
30+
console.log(` Reference: ${this.referenceDir}`);
31+
console.log(` Output: ${this.outputDir}`);
1932
}
2033

2134
/**

example/e2e/snapshots/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
output/*
33

44
# Keep reference snapshots (golden images for comparison)
5+
# Platform-specific: reference/ios/ and reference/android/
56
!reference/
7+
!reference/ios/
8+
!reference/ios/*.png
9+
!reference/android/
10+
!reference/android/*.png
611
!reference/.gitkeep
712

813
# Keep directory structure
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Android reference snapshots will be generated here when running UPDATE_SNAPSHOTS=true on Android

0 commit comments

Comments
 (0)