-
Notifications
You must be signed in to change notification settings - Fork 14
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
Changes from 8 commits
78e591e
734e696
1c63807
b939ae6
fdd74de
7b257ad
4a8c76c
d91ea99
11aebab
6fd2d83
bd45e21
dbf2c61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were moved here from the root |
||
}, | ||
"dependencies": { | ||
"@react-native-picker/picker": "2.5.1", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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/'), | ||
}, | ||
}, | ||
], | ||
], | ||
}; |
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); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
}, | ||
}); |
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)); | ||
}); | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ExampleSpec from './exampleSpec'; | ||
|
||
export default [ExampleSpec]; |
There was a problem hiding this comment.
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.