Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player testing: Cavy framework setup #331

Merged
merged 12 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to install yarn dependencies for the integration tests as well to allow typescript related validation.

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 example project by installing all dependencies and pods.
rolandkakonyi marked this conversation as resolved.
Show resolved Hide resolved
- `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 example app.
rolandkakonyi marked this conversation as resolved.
Show resolved Hide resolved
- `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"
Comment on lines +10 to +12
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were moved here from the root package.json to separate concerns

},
"dependencies": {
"@react-native-picker/picker": "2.5.1",
Expand Down
14 changes: 14 additions & 0 deletions integration_test/babel.config.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes here mirror the one from the example app

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);
4 changes: 2 additions & 2 deletions integration_test/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ PODS:
- React-jsi (= 0.72.6-1)
- React-logger (= 0.72.6-1)
- React-perflogger (= 0.72.6-1)
- RNBitmovinPlayer (0.14.1):
- RNBitmovinPlayer (0.14.2):
- BitmovinPlayer (= 3.49.0)
- GoogleAds-IMA-iOS-SDK (= 3.18.4)
- GoogleAds-IMA-tvOS-SDK (= 4.8.2)
Expand Down Expand Up @@ -707,7 +707,7 @@ SPEC CHECKSUMS:
React-runtimescheduler: acd6b708338a975a9bb4c594eac0f018f5c15fa3
React-utils: c1cf85c0cd58c11dfb95104a78c608e95d03eb9e
ReactCommon: 1dabb8f37c44d8c7370238bd8f504cbad0cfd941
RNBitmovinPlayer: 29822e8853cfc97c179ab24cda7902ecf6f3f1e0
RNBitmovinPlayer: 020d9bcad225ddee065212cbba660673e456f391
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: f67f5769ce78049c5fe798bc735f04535c7bc1ac
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
Expand Down
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:[email protected]"
},
"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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a very basic setup which gets modified for actual player testing in #332

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a placeholder test to prove the framework works

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