Skip to content

Commit

Permalink
Write test report
Browse files Browse the repository at this point in the history
  • Loading branch information
tvanlaerhoven committed Oct 30, 2024
1 parent aae4aa8 commit fad3245
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/pr_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@ jobs:
force-avd-creation: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: npm run test:e2e:android:release
script: |
npm run test:e2e:android:release
e2e_summary=$(adb logcat -d -v raw | grep "E2E_RESULTS" | sed "s/'E2E_RESULTS', //")
echo "$e2e_summary" | tee -a $GITHUB_STEP_SUMMARY
working-directory: e2e
17 changes: 15 additions & 2 deletions e2e/src/TestableApp.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Tester, TestHookStore } from 'cavy';
import { Tester, TestHookStore, TestReport } from 'cavy';
import { Platform, SafeAreaView, StyleSheet, View, ViewStyle } from 'react-native';
import { TestableTHEOplayerView } from './components/TestableTHEOplayerView';
import Specs from './tests';
Expand All @@ -19,10 +19,23 @@ const PLAYER_CONTAINER_STYLE: ViewStyle = {
backgroundColor: '#000000',
};

const generateTable = (report: TestReport): string => {
return (
`|Description|'Test results 🧪'|\n` +
`|---|---|\n` +
report.results.map((result) => `|${result.message} | ${result.passed ? '✅' : '❌'}|`).join('\n')
);
};

const reporter = (report: TestReport) => {
// Write the test results to a github workflow summary.
console.log(`E2E_RESULTS`, `### E2E Test Summary\n` + generateTable(report));
};

export class TestableApp extends Component {
render() {
return (
<Tester specs={Specs} store={testHookStore}>
<Tester specs={Specs} store={testHookStore} reporter={reporter}>
<SafeAreaView style={[StyleSheet.absoluteFill, { backgroundColor: '#000000' }]}>
<View style={PLAYER_CONTAINER_STYLE}>
<TestableTHEOplayerView />
Expand Down

0 comments on commit fad3245

Please sign in to comment.