Skip to content

Commit

Permalink
Use cavy-cli to generate summary
Browse files Browse the repository at this point in the history
  • Loading branch information
tvanlaerhoven committed Oct 30, 2024
1 parent c493479 commit efced5c
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 135 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pr_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,5 @@ jobs:
disable-animations: true
script: |
npm run test:e2e:android
echo "### E2E Test Summary" >> $GITHUB_STEP_SUMMARY
echo $(adb logcat -d -v raw | grep "E2E_RESULTS" | sed "s/'E2E_RESULTS', '//") >> $GITHUB_STEP_SUMMARY
cat cavy_results.md >> $GITHUB_STEP_SUMMARY
working-directory: e2e
4 changes: 3 additions & 1 deletion .github/workflows/pr_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ jobs:

- name: Run e2e tests
working-directory: e2e
run: npm run test:e2e:ios
run: |
npm run test:e2e:ios
cat cavy_results.md >> $GITHUB_STEP_SUMMARY
15 changes: 15 additions & 0 deletions e2e/cavy_results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### E2E Test Summary|Description 📝|Test results 🧪|Duration ⏰|
|---|---|---|
|Set HLS source and auto-play: dispatches sourcechange event on setting a source without autoplay||0.732s|
|Set HLS source and auto-play: dispatches sourcechange, play and playing events in order on setting a source with autoplay||1.698s|
|Set HLS source and auto-play: dispatches a seeked event after seeking||1.786s|
|Set HLS source and auto-play: dispatches paused, play and playing events after pausing & resuming playback||0.836s|
|Set mp4 source and auto-play: dispatches sourcechange event on setting a source without autoplay||0.176s|
|Set mp4 source and auto-play: dispatches sourcechange, play and playing events in order on setting a source with autoplay||1.586s|
|Set mp4 source and auto-play: dispatches a seeked event after seeking||1.961s|
|Set mp4 source and auto-play: dispatches paused, play and playing events after pausing & resuming playback||2.042s|
|Set source with ads and auto-play: dispatches sourcechange, play, playing and ad events||10.171s|
|Setup Conviva connector: successfully creates the connector, connects to the player, uses API, and cleans up and destroys.||0.712s|
|Setup Nielsen connector: successfully creates the connector, connects to the player, uses API, and cleans up and destroys.||0.884s|
|Setup Adobe connector: successfully creates the connector, connects to the player, uses API, and cleans up and destroys.||0.916s|
|Switch between presentation modes: dispatches presentationmodechange events between inline and fullscreen.||1.352s|
4 changes: 2 additions & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"private": true,
"scripts": {
"start": "npx react-native start",
"test:e2e:android": "npx cavy run-android --terminal bash --mode release",
"test:e2e:ios": "npx cavy run-ios --terminal bash",
"test:e2e:android": "npx cavy run-android --md --terminal bash --mode release",
"test:e2e:ios": "npx cavy run-ios --md --terminal bash",
"lint": "eslint \"**/*.{ts,tsx}\"",
"postinstall": "patch-package"
},
Expand Down
27 changes: 0 additions & 27 deletions e2e/patches/@types+cavy+3.2.9.patch

This file was deleted.

27 changes: 0 additions & 27 deletions e2e/patches/cavy+4.0.2.patch

This file was deleted.

118 changes: 118 additions & 0 deletions e2e/patches/cavy-cli+3.0.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
diff --git a/node_modules/cavy-cli/cavy.js b/node_modules/cavy-cli/cavy.js
index da9fc72..c3d3b41 100755
--- a/node_modules/cavy-cli/cavy.js
+++ b/node_modules/cavy-cli/cavy.js
@@ -32,9 +32,10 @@ function test(cmd) {
const entryFile = cmd.file;
const skipbuild = cmd.skipbuild;
const outputAsXml = cmd.xml;
+ const outputAsMarkdown = cmd.md;
const dev = cmd.dev;
const bootTimeout = cmd.bootTimeout;
- runTests(commandName, entryFile, skipbuild, dev, outputAsXml, bootTimeout, args);
+ runTests(commandName, entryFile, skipbuild, dev, outputAsXml, outputAsMarkdown, bootTimeout, args);
}

// Stop quitting unless we want to
@@ -64,6 +65,7 @@ program
+ '(is ignored if used with --skipbuild, defaults to 2 minutes, requires Cavy 4.0.0)'
)
.option('--xml', 'Write out test results to cavy_results.xml (requires Cavy 3.3.0)')
+ .option('--md', 'Write out test results to cavy_results.md')
.allowUnknownOption()
.action(cmd => test(cmd));

@@ -82,6 +84,7 @@ program
+ '(is ignored if used with --skipbuild, defaults to 2 minutes, requires Cavy 4.0.0)'
)
.option('--xml', 'Write out test results to cavy_results.xml (requires Cavy 3.3.0)')
+ .option('--md', 'Write out test results to cavy_results.md')
.allowUnknownOption()
.action(cmd => test(cmd));

diff --git a/node_modules/cavy-cli/server.js b/node_modules/cavy-cli/server.js
index 64faf22..8ecf8b3 100644
--- a/node_modules/cavy-cli/server.js
+++ b/node_modules/cavy-cli/server.js
@@ -2,6 +2,7 @@ const http = require('http');
const WebSocket = require('ws');
const chalk = require('chalk');
const constructXML = require('./src/junitFormatter');
+const { writeFileSync } = require('fs');

// Initialize a server
const server = http.createServer();
@@ -62,6 +63,18 @@ function logTestResult(testResultJson) {
}
};

+function constructMarkdown(results) {
+ const filename = 'cavy_results.md';
+ console.log(`Writing results to ${filename}`);
+ const data =
+ `### E2E Test Summary\n` +
+ `|Description 📝|Test results 🧪|Duration ⏰|\n` +
+ `|---|---|---|\n` +
+ results.testCases.map((result) => `|${result.description}|${result.passed ? `✅` : `❌`}|${result.time}s|`).join('\n');
+
+ writeFileSync(filename, data);
+};
+
// Internal: Accepts a json report object, console.logs the overall result of
// the test suite and quits the process with either exit code 1 or 0 depending
// on whether any tests failed.
@@ -81,6 +94,11 @@ function finishTesting(reportJson) {
constructXML(fullResults);
}

+ // If requested, construct XML report.
+ if (server.locals.outputAsMarkdown) {
+ constructMarkdown(fullResults);
+ }
+
// If all tests pass, exit with code 0, else code 42.
// Code 42 chosen at random so that a test failure can be distinuguished from
// a build failure (in which case the React Native CLI would exit with code 1).
diff --git a/node_modules/cavy-cli/src/runTests.js b/node_modules/cavy-cli/src/runTests.js
index 69ef62c..9eb750e 100644
--- a/node_modules/cavy-cli/src/runTests.js
+++ b/node_modules/cavy-cli/src/runTests.js
@@ -57,9 +57,10 @@ function getAdbPath() {
}

// Start test server, listening for test results to be posted.
-function runServer({ command, dev, outputAsXml, skipbuild, bootTimeout }) {
+function runServer({ command, dev, outputAsXml, outputAsMarkdown, skipbuild, bootTimeout }) {
server.locals.dev = dev;
server.locals.outputAsXml = outputAsXml;
+ server.locals.outputAsMarkdown = outputAsMarkdown;
server.listen(8082, () => {
if (command == 'run-android') {
runAdbReverse();
@@ -93,7 +94,7 @@ function runServer({ command, dev, outputAsXml, skipbuild, bootTimeout }) {
// outputAsXml: whether to write and save the results to XML file
// bootTimeout: how long the CLI should wait for the RN app to boot.
// args: any extra arguments the user would usually to pass to `react native run...`
-function runTests(command, file, skipbuild, dev, outputAsXml, bootTimeout, args) {
+function runTests(command, file, skipbuild, dev, outputAsXml, outputAsMarkdown, bootTimeout, args) {

// Assume entry file is 'index.js' if user doesn't supply one.
const entryFile = file || 'index.js';
@@ -134,7 +135,7 @@ function runTests(command, file, skipbuild, dev, outputAsXml, bootTimeout, args)
});

if (skipbuild) {
- runServer({ command, dev, outputAsXml, skipbuild, bootTimeout });
+ runServer({ command, dev, outputAsXml, outputAsMarkdown, skipbuild, bootTimeout });
} else {
// Build the app, start the test server and wait for results.
console.log(`cavy: Running \`npx react-native ${command}\`...`);
@@ -151,7 +152,7 @@ function runTests(command, file, skipbuild, dev, outputAsXml, bootTimeout, args)
if (code) {
return process.exit(code);
}
- runServer({ command, dev, outputAsXml, skipbuild, bootTimeout });
+ runServer({ command, dev, outputAsXml, outputAsMarkdown, skipbuild, bootTimeout });
});
}
}
3 changes: 1 addition & 2 deletions e2e/src/TestableApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Platform, SafeAreaView, StyleSheet, View, ViewStyle } from 'react-nativ
import { TestableTHEOplayerView } from './components/TestableTHEOplayerView';
import Specs from './tests';
import { getStatusBarHeight } from 'react-native-status-bar-height';
import { Reporter } from './utils/TestReporter';

const testHookStore = new TestHookStore();

Expand All @@ -23,7 +22,7 @@ const PLAYER_CONTAINER_STYLE: ViewStyle = {
export class TestableApp extends Component {
render() {
return (
<Tester specs={Specs} store={testHookStore} reporter={Reporter}>
<Tester specs={Specs} store={testHookStore}>
<SafeAreaView style={[StyleSheet.absoluteFill, { backgroundColor: '#000000' }]}>
<View style={PLAYER_CONTAINER_STYLE}>
<TestableTHEOplayerView />
Expand Down
74 changes: 0 additions & 74 deletions e2e/src/utils/TestReporter.ts

This file was deleted.

0 comments on commit efced5c

Please sign in to comment.