Repository navigation
Expand file tree
/
Copy pathApp.tsx
More file actions
81 lines (76 loc) · 2.12 KB
/
Copy pathApp.tsx
File metadata and controls
81 lines (76 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { StatusBar } from 'expo-status-bar';
import { useEffect, useState } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
/**
* Example harness — Pattern C dedicated test app.
* On mount: exercise fixture-lib then flush native coverage (Appium later).
*/
export default function App() {
const [lastHit, setLastHit] = useState<number | null>(null);
const [status, setStatus] = useState('idle');
const runCoverageDemo = () => {
try {
// Lazy require so Metro still loads if native binary is missing in Expo Go.
const { hit } = require('coverage-fixture');
const { flush } = require('react-native-coverage');
const value = hit();
flush();
setLastHit(value);
setStatus(`hit=${value}; flush invoked`);
console.log('[example] fixture hit + flush', value);
} catch (error) {
setStatus(`unavailable: ${String(error)}`);
console.warn('[example] coverage demo unavailable', error);
}
};
useEffect(() => {
runCoverageDemo();
}, []);
return (
<View style={styles.container} testID="coverage-root">
<Text style={styles.title} testID="coverage-title">
react-native-coverage
</Text>
<Text style={styles.subtitle} testID="coverage-cell">
Expo static cell + CoverageFixture
</Text>
<Text style={styles.status} testID="coverage-status">
{status}
</Text>
{lastHit != null ? (
<Text style={styles.status} testID="coverage-last-hit">
last hit accumulator: {lastHit}
</Text>
) : null}
<Button
title="Hit fixture + flush"
onPress={runCoverageDemo}
testID="coverage-hit-button"
/>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
gap: 12,
},
title: {
fontSize: 20,
fontWeight: '600',
},
subtitle: {
color: '#666',
marginBottom: 8,
},
status: {
color: '#333',
fontSize: 13,
textAlign: 'center',
paddingHorizontal: 24,
},
});