-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(react-native): add rendering metrics e2e test
- Loading branch information
1 parent
97aeffe
commit 4c52934
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
test/react-native/features/fixtures/scenario-launcher/scenarios/RenderingMetricsScenario.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, { useEffect } from 'react' | ||
import { SafeAreaView, View, Text, StyleSheet, FlatList } from 'react-native' | ||
import { NativeScenarioLauncher } from '../lib/native' | ||
import BugsnagPerformance from '@bugsnag/react-native-performance' | ||
|
||
export const doNotStartBugsnagPerformance = true | ||
|
||
const listData = Array.from({ length: 10000 }, (_, index) => { return { name: `Item ${index + 1}` } }) | ||
|
||
export const initialise = async (config) => { | ||
const nativeConfig = { | ||
apiKey: config.apiKey, | ||
endpoint: config.endpoint | ||
} | ||
|
||
await NativeScenarioLauncher.startNativePerformance(nativeConfig) | ||
|
||
BugsnagPerformance.attach({ maximumBatchSize: 1, autoInstrumentAppStarts: false, autoInstrumentNetworkRequests: false }) | ||
} | ||
|
||
export const App = () => { | ||
let nativeSpan = BugsnagPerformance.startSpan('RenderingMetricsScenario', { isFirstClass: true }) | ||
|
||
const renderItem = (item, index) => { | ||
return ( | ||
<View> | ||
<Text>{item.name}</Text> | ||
</View> | ||
) | ||
} | ||
|
||
useEffect(() => { | ||
nativeSpan.end() | ||
}, []) | ||
|
||
return ( | ||
<SafeAreaView style={styles.container}> | ||
<View style={styles.scenario}> | ||
<Text>Rendering Metrics Scenario</Text> | ||
<FlatList data={listData} renderItem={({ item, index }) => renderItem(item, index)} /> | ||
</View> | ||
</SafeAreaView> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1 | ||
}, | ||
scenario: { | ||
flex: 1 | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@native_integration | ||
Feature: Rendering Metrics | ||
|
||
Scenario: Rendering metrics are reported | ||
When I run 'RenderingMetricsScenario' | ||
And I wait to receive a sampling request | ||
And I wait to receive 1 traces | ||
|
||
# Native trace | ||
Then the trace payload field "resourceSpans.0.resource" string attribute "service.name" equals "com.bugsnag.fixtures.reactnative.performance" | ||
And the trace payload field "resourceSpans.0.resource" string attribute "telemetry.sdk.name" equals the platform-dependent string: | ||
| ios | bugsnag.performance.cocoa | | ||
| android | bugsnag.performance.android | | ||
|
||
And a span name equals "RenderingMetricsScenario" |