Skip to content

Commit ba0482f

Browse files
committed
fix(example): fix detox screenshot tests and suppress LogBox warning
- Move LogBox.ignoreLogs to setup.js (loaded before mapbox imports) - Add whileElement scroll for off-screen example groups - Add per-example disableSync metadata for tests with JS timers - Blacklist mapbox tile URLs to prevent Detox sync timeouts - Fix Ornaments example missing default camera position - Add Detox e2e docs to CLAUDE.md
1 parent fb73127 commit ba0482f

File tree

9 files changed

+37
-13
lines changed

9 files changed

+37
-13
lines changed

AGENTS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,19 @@ RCT_NEW_ARCH_ENABLED=1 pod update MapboxMaps
127127
- Example app serves as integration testing ground
128128
- Use `yarn test` before committing
129129

130+
### E2E / Doc Screenshots (Detox)
131+
```bash
132+
cd example
133+
yarn detox build --configuration ios.debug
134+
yarn detox test --configuration ios.debug ./e2e/docScreenshots.e2e.js
135+
# Run a single test:
136+
yarn detox test --configuration ios.debug ./e2e/docScreenshots.e2e.js --testNamePattern="ImageOverlay"
137+
```
138+
- Screenshots are captured from every example and saved to `../maps-docs/examples-screenshots/`
139+
- Config: `scripts/autogenHelpers/docconfig.js`
140+
- Examples with JS timers or animations that block Detox sync should set `disableSync: true` in their metadata
141+
- `device.setURLBlacklist` in beforeEach prevents Detox from waiting on tile network requests
142+
130143
### Documentation
131144
- Component docs are auto-generated from JSDoc comments
132145
- Don't edit `.md` files in `docs/` directly - edit source files and run `yarn generate`

docs/examples.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,8 @@
716716
"RasterLayer",
717717
"ImageSource"
718718
],
719-
"docs": ""
719+
"docs": "",
720+
"disableSync": true
720721
},
721722
"fullPath": "example/src/examples/FillRasterLayer/ImageOverlay.js",
722723
"relPath": "FillRasterLayer/ImageOverlay.js",

example/e2e/docScreenshots.e2e.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ if (['true', 1, '1'].includes(process.env.SKIP_TESTS_NO_METAL)) {
170170
if (shouldRestartAppBetweenTests) {
171171
await device.launchApp({ permissions: { location: 'always' } });
172172
}
173+
await device.setURLBlacklist([
174+
'.*tile.openstreetmap.org.*',
175+
'.*mapbox.com.*',
176+
]);
173177
await device.reloadReactNative();
174178
});
175179
afterEach(async () => {
@@ -198,24 +202,27 @@ if (['true', 1, '1'].includes(process.env.SKIP_TESTS_NO_METAL)) {
198202
});
199203
await setSampleLocation();
200204

201-
await expect(
202-
element(by.text(groupMetadata.title)),
203-
).toBeVisible();
205+
await waitFor(element(by.text(groupMetadata.title)))
206+
.toBeVisible()
207+
.whileElement(by.id('example-list'))
208+
.scroll(200, 'down');
204209
await element(by.text(groupMetadata.title)).tap();
205210

206211
await waitFor(element(by.text(metadata.title)))
207212
.toBeVisible()
208213
.whileElement(by.id('example-list'))
209214
.scroll(50, 'down');
215+
if (metadata.disableSync) {
216+
await device.disableSynchronization();
217+
}
210218
await element(by.text(metadata.title)).tap();
211219

212220
let shots = new ExampleScreenshots(
213221
{ testName: name, groupName },
214222
screenshots,
215223
);
216224

217-
await wait(1000);
218-
225+
await wait(metadata.disableSync ? 3000 : 1000);
219226
await shots.screenshot();
220227
});
221228
}

example/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
console.log('index.js');
2+
import './src/setup';
23
import { AppRegistry } from 'react-native';
34

45
import App from './src/App';

example/src/App.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import Mapbox from '@rnmapbox/maps';
3-
import { StyleSheet, Text, View, LogBox } from 'react-native';
3+
import { StyleSheet, Text, View } from 'react-native';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55
import { NavigationContainer } from '@react-navigation/native';
66
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
@@ -13,11 +13,6 @@ import { Group, Item } from './scenes/GroupAndItem';
1313
import { ScreenWithoutMap } from './scenes/ScreenWithoutMap';
1414
import MapInModal from './examples/Map/MapInModal';
1515

16-
LogBox.ignoreLogs([
17-
'Warning: isMounted(...) is deprecated',
18-
'Module RCTImageLoader',
19-
]);
20-
2116
const styles = StyleSheet.create({
2217
noPermissionsText: {
2318
fontSize: 18,

example/src/examples/FillRasterLayer/ImageOverlay.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,6 @@ const metadata = {
120120
title: 'Image Overlay',
121121
tags: ['RasterLayer', 'ImageSource'],
122122
docs: '',
123+
disableSync: true,
123124
};
124125
ImageOverlay.metadata = metadata;

example/src/examples/Map/Ornaments.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const Ornaments = () => {
130130
scaleBarPosition={POSITIONS[position[OrnamentType.ScaleBar]]}
131131
>
132132
<Images images={images} />
133-
<Camera />
133+
<Camera zoomLevel={4} centerCoordinate={[-98, 38.88]} />
134134
</MapView>
135135

136136
<Bubble style={styles.bubble}>

example/src/examples/common/ExampleMetadata.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export type ExampleMetadata = {
22
title: string;
33
tags: string[];
44
docs: string;
5+
disableSync?: boolean;
56
};
67

78
export type ExampleWithMetadata = React.ComponentType & {

example/src/setup.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { LogBox } from 'react-native';
2+
3+
LogBox.ignoreLogs([
4+
"Deep imports from the 'react-native' package are deprecated ('react-native/Libraries/Utilities/codegenNativeComponent')",
5+
]);

0 commit comments

Comments
 (0)