Skip to content

Commit c6e813e

Browse files
mickeywumikehardy
andauthored
feat(app-check, expo): add config plugin for iOS module initialization (#7662)
* Create config plugin for App Check * Update tests * Update packages/app-check/plugin/__tests__/README.md * add expo dep needed for plugin, update snapshots, auto-fix lint error --------- Co-authored-by: Mike Hardy <[email protected]>
1 parent fae5966 commit c6e813e

File tree

16 files changed

+1189
-1
lines changed

16 files changed

+1189
-1
lines changed

docs/app-check/usage/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ For instructions on how to generate required keys and register an app for the de
8585
8686
## Initialize
8787

88+
> If you're using Expo Managed Workflow, you can load the `@react-native-firebase/app-check` config plugin to skip the Initialize setup step.
89+
8890
You must call initialize the AppCheck module prior to calling any firebase back-end services for App Check to function.
8991

9092
To do that, edit your `ios/ProjectName/AppDelegate.mm` and add the following two lines:

packages/app-check/app.plugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./plugin/build');

packages/app-check/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@
2323
"appCheck"
2424
],
2525
"peerDependencies": {
26-
"@react-native-firebase/app": "19.0.1"
26+
"@react-native-firebase/app": "19.0.1",
27+
"expo": ">=47.0.0"
28+
},
29+
"devDependencies": {
30+
"expo": "^49.0.21"
31+
},
32+
"peerDependenciesMeta": {
33+
"expo": {
34+
"optional": true
35+
}
2736
},
2837
"publishConfig": {
2938
"access": "public"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Expo Config Plugin unit tests
2+
3+
To test the changes to native code applied by config plugins, [snapshot tests](https://jestjs.io/docs/snapshot-testing) are used. Plugin test flow, in short:
4+
5+
1. A test fixture is loaded. In this case, fixtures are template files (`build.gradle`, `AppDelegate.m` etc.) from [`expo-template-bare-minimum`](https://github.com/expo/expo/tree/main/templates/expo-template-bare-minimum).
6+
2. Plugin changes are applied (e.g. gradle dependency is added).
7+
3. Modified file is compared with previously saved snapshot. If they're equal, the test passes. If not, the test fails and the difference (actual vs expected) is shown.
8+
9+
You can preview the snapshot files manually, by opening `__snapshots__/*.snap` files.
10+
11+
### Updating the snapshots
12+
13+
Snapshot tests are designed to ensure the plugin result will not change. In case you intentionally modified the plugin behavior (e.g. updated gradle dependency versions), you have to update the snapshots, otherwise the tests will fail. There are two ways to do it:
14+
15+
- Update all snapshots by running `npm run tests:jest -u`.
16+
- Update snapshots interactively, one by one:
17+
1. Run `yarn tests:jest --watchAll`
18+
2. Press `i` to let `jest` display changes and prompt you for updating each snapshot.
19+
> This option is not available, when there are no failing snapshots

0 commit comments

Comments
 (0)