Skip to content

Commit

Permalink
feat: example test in new test harness works
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehardy committed Oct 6, 2021
1 parent 4c27d78 commit 2041fa2
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 24 deletions.
15 changes: 0 additions & 15 deletions example/App.js

This file was deleted.

56 changes: 56 additions & 0 deletions example/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react';
import {SafeAreaView, ScrollView, Text, View} from 'react-native';
import {
AutoExecutableTest,
TestRegistry,
TestResult,
TestRunner,
TestType,
} from 'jet';

// To implement a test you must make a new object implementing a specific interface.
class ExampleTest implements AutoExecutableTest {
getPath(): string {
return 'Example';
}

getTestType(): TestType {
return TestType.AutoExecutable;
}

render(onMount: (component: any) => void): React.ReactNode {
return (
<View ref={onMount}>
<Text>
{'This is rendered if a user taps the test in the test list.'}
</Text>
</View>
);
}

execute(component: any, complete: (result: TestResult) => void): void {
let results = new TestResult();
try {
// You can do anything here, it will execute on-device + in-app. Results are aggregated + visible in-app.
} catch (error) {
results.errors.push('Received unexpected error...');
} finally {
complete(results);
}
}
}

// All tests must be registered - a future feature will allow auto-bundling of tests via configured path or regex
TestRegistry.registerTest(new ExampleTest());

const App = () => {
return (
<SafeAreaView>
<ScrollView contentInsetAdjustmentBehavior="automatic">
<TestRunner />
</ScrollView>
</SafeAreaView>
);
};

export default App;
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ DEPENDENCIES:
- FlipperKit/FlipperKitUserDefaultsPlugin (= 0.99.0)
- FlipperKit/SKIOSNetworkPlugin (= 0.99.0)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- Jet (from `../../../jet`)
- Jet (from `../node_modules/jet`)
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
Expand Down Expand Up @@ -481,7 +481,7 @@ EXTERNAL SOURCES:
glog:
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
Jet:
:path: "../../../jet"
:path: "../node_modules/jet"
RCT-Folly:
:podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec"
RCTRequired:
Expand Down Expand Up @@ -590,6 +590,6 @@ SPEC CHECKSUMS:
Yoga: c11abbf5809216c91fcd62f5571078b83d9b6720
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 0b0ac2b8a282e404bea9bc7aaef089cbf0b0529d
PODFILE CHECKSUM: c9dfce8cacb6ff1a67677cf35bdcb7d536fb14d4

COCOAPODS: 1.11.2
5 changes: 3 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
"lint": "eslint .",
"postinstall": "cd node_modules/jet && yarn"
},
"dependencies": {
"@invertase/react-native-google-ads": "link:../",
"jet": "link:../../jet/",
"jet": "https://github.com/invertase/jet.git#ff3f9bec4a53f7f1e1c05dcc97abede26c72e72f",
"react": "17.0.2",
"react-native": "0.66.0"
},
Expand Down
19 changes: 16 additions & 3 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4211,9 +4211,22 @@ jest@^26.6.3:
import-local "^3.0.2"
jest-cli "^26.6.3"

"jet@link:../../jet/":
version "0.0.0"
uid ""
"jet@https://github.com/invertase/jet.git#ff3f9bec4a53f7f1e1c05dcc97abede26c72e72f":
version "0.4.2"
resolved "https://github.com/invertase/jet.git#ff3f9bec4a53f7f1e1c05dcc97abede26c72e72f"
dependencies:
chalk "^4.1.2"
error-stack-parser "^2.0.2"
istanbul-lib-coverage "^3.0.1"
should "^13.2.1"
should-sinon "0.0.6"
sinon "^11.1.2"
source-map "^0.7.3"
tinyqueue "^2.0.3"
ws "^8.2.3"
optionalDependencies:
detox "^18.22.1"
mocha "^9.1.2"

jetifier@^1.6.2:
version "1.6.8"
Expand Down
2 changes: 1 addition & 1 deletion refresh-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ sed -i -e $'s/react_native_post_install(installer)/react_native_post_install(ins
rm -f ios/Podfile??

# run pod install after installing our module
cd ios && pod install && cd ..
npx pod-install

# Copy the important files back in
popd
Expand Down

0 comments on commit 2041fa2

Please sign in to comment.