Skip to content

Commit

Permalink
Merge pull request #331 from bitmovin/player-testing/cavy-setup
Browse files Browse the repository at this point in the history
Player testing: Cavy framework setup
  • Loading branch information
rolandkakonyi authored Dec 13, 2023
2 parents d8a6d02 + dbf2c61 commit eb3fe01
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 31 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ jobs:
- name: Install node_modules (example/)
run: yarn install --frozen-lockfile --cwd example

- name: Install node_modules (integration_test/)
run: yarn install --frozen-lockfile --cwd integration_test

- name: Compile TypeScript
run: yarn typescript

Expand All @@ -117,6 +120,9 @@ jobs:
- name: Install node_modules (example/)
run: yarn install --frozen-lockfile --cwd example

- name: Install node_modules (integration_test/)
run: yarn install --frozen-lockfile --cwd integration_test

- name: Build docs
run: yarn docs

Expand Down Expand Up @@ -146,6 +152,9 @@ jobs:
- name: Install node_modules (example/)
run: yarn install --frozen-lockfile --cwd example

- name: Install node_modules (integration_test/)
run: yarn install --frozen-lockfile --cwd integration_test

- name: Set up Gradle cache
uses: gradle/gradle-build-action@v2
with:
Expand Down
14 changes: 11 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,20 @@ Our pre-commit hooks verify that your commit message matches this format when co

The `package.json` file contains various scripts for common tasks:

- `yarn bootstrap`: setup project by installing all dependencies and pods.
- `yarn pods`: install pods only.
- `yarn bootstrap`: setup the whole project by installing all dependencies and pods.
- `yarn bootstrap:example`: setup example project by installing all dependencies and pods.
- `yarn bootstrap:integration-test`: setup integration tests project by installing all dependencies and pods.
- `yarn build`: compile TypeScript files into `lib/` with ESBuild.
- `yarn typescript`: type-check files with TypeScript.
- `yarn lint`: lint files with ESLint.
- `yarn test`: run unit tests with Jest.
- `yarn format`: format files with Prettier.
- `yarn docs`: generate documentation with TypeDoc.
- `yarn brew`: install all dependencies for iOS development with Homebrew.
- `yarn example start`: start the Metro server for the example app.
- `yarn example android`: run the example app on Android.
- `yarn example pods`: install pods only.
- `yarn integration-test start`: start the Metro server for the integration tests.
- `yarn integration-test test:android`: run the player tests on Android.
- `yarn integration-test test:ios`: run the player tests on iOS.
- `yarn integration-test pods`: install pods only.
- `yarn example ios`: run the example app on iOS.
5 changes: 4 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start"
"start": "react-native start",
"pods": "yarn pods-install || yarn pods-update",
"pods-install": "yarn pod-install",
"pods-update": "pod update --silent"
},
"dependencies": {
"@react-native-picker/picker": "2.5.1",
Expand Down
14 changes: 14 additions & 0 deletions integration_test/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
const path = require('path');
const pak = require('../package.json');

module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolver',
{
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: {
[pak.name]: path.join(__dirname, '../src/'),
},
},
],
],
};
5 changes: 5 additions & 0 deletions integration_test/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AppRegistry } from 'react-native';
import TestableApp from './src/TestableApp';
import { name as appName } from './app.json';

AppRegistry.registerComponent(appName, () => TestableApp);
12 changes: 9 additions & 3 deletions integration_test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,32 @@
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"playertest:android": "yarn cavy run-android",
"playertest:ios": "yarn cavy run-ios",
"pods": "yarn pods-install || yarn pods-update",
"pods-install": "yarn pod-install",
"pods-update": "pod update --silent"
},
"dependencies": {
"cavy": "^4.0.2",
"react": "18.2.0",
"react-native": "npm:react-native-tvos@0.72.6-1"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@tsconfig/react-native": "^3.0.0",
"@types/react": "^18.0.24",
"@react-native/metro-config": "^0.72.11",
"babel-plugin-module-resolver": "^5.0.0",
"metro-react-native-babel-preset": "0.76.8",
"pod-install": "^0.1.39",
"typescript": "4.8.4"
"@types/cavy": "^3.2.7",
"cavy-cli": "^3.0.0"
},
"engines": {
"node": ">=16"
},
"resolutions": {
"@types/react": "~17.0.21"
}
}
32 changes: 32 additions & 0 deletions integration_test/src/TestableApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { Tester, TestHookStore } from 'cavy';
import Specs from '../tests';
import { StyleSheet, Text, View } from 'react-native';
import { Colors } from 'react-native/Libraries/NewAppScreen';

const testHookStore = new TestHookStore();

function TestableApp(): JSX.Element {
return (
<Tester specs={Specs} store={testHookStore}>
<View style={styles.container}>
<Text style={styles.text}>Tests will come here</Text>
</View>
</Tester>
);
}

export default TestableApp;

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 10,
},
text: {
fontSize: 24,
color: Colors.darker,
},
});
9 changes: 9 additions & 0 deletions integration_test/tests/exampleSpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { TestScope } from 'cavy';

export default (spec: TestScope) => {
spec.describe('cavy', () => {
spec.it('works', async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
});
});
};
3 changes: 3 additions & 0 deletions integration_test/tests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ExampleSpec from './exampleSpec';

export default [ExampleSpec];
Loading

0 comments on commit eb3fe01

Please sign in to comment.