Skip to content

Commit 268c659

Browse files
authored
test: harden app monitor command seams (#118)
## Summary - move app monitor tests off raw `tools.spawn` mocks by introducing wrapper helpers for Android logcat and iOS simulator log streaming - keep command-shape assertions in `adb` and `simctl` wrapper tests where the shell boundary is the actual behavior under test - preserve full test coverage for the refactor and verify the repo-wide test suite still passes ## Testing - `pnpm vitest src/__tests__/app-monitor.test.ts src/__tests__/adb.test.ts` - `pnpm vitest src/__tests__/app-monitor.test.ts src/__tests__/simctl.test.ts` - `pnpm test:all`
1 parent 5747dda commit 268c659

22 files changed

Lines changed: 202 additions & 1364 deletions

action.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ runs:
6565
exit 1
6666
fi
6767
- name: Metro bundler cache (.harness/metro-cache)
68-
uses: actions/cache@v4
68+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
6969
with:
7070
path: ${{ steps.load-config.outputs.projectRoot }}/.harness/metro-cache
7171
key: ${{ runner.os }}-metro-cache-${{ hashFiles('**/bun.lock', '**/bun.lockb', '**/package-lock.json', '**/npm-shrinkwrap.json', '**/pnpm-lock.yaml', '**/yarn.lock', '**/metro.config.js', '**/metro.config.cjs', '**/metro.config.mjs', '**/metro.config.ts', '**/babel.config.js', '**/babel.config.cjs', '**/babel.config.mjs', '**/babel.config.ts', '**/babel.config.json') }}
@@ -74,7 +74,7 @@ runs:
7474
- name: Restore Harness cache
7575
id: cache-harness-restore
7676
if: fromJson(steps.load-config.outputs.config).platformId == 'ios'
77-
uses: actions/cache/restore@v4
77+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
7878
with:
7979
path: ${{ steps.load-config.outputs.projectRoot }}/.harness/cache
8080
key: harness-ios-${{ runner.os }}-${{ hashFiles(format('{0}/.harness/cache/**/cache.json', steps.load-config.outputs.projectRoot)) }}
@@ -132,7 +132,7 @@ runs:
132132
CACHE_KEY="avd-$AVD_NAME-$ARCH-$AVD_CONFIG_HASH"
133133
echo "key=$CACHE_KEY" >> $GITHUB_OUTPUT
134134
- name: Restore AVD cache
135-
uses: actions/cache/restore@v4
135+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
136136
id: avd-cache
137137
if: ${{ fromJson(steps.load-config.outputs.config).platformId == 'android' && fromJson(steps.load-config.outputs.config).config.device.type == 'emulator' && fromJson(steps.load-config.outputs.config).action.avdCachingEnabled }}
138138
with:
@@ -221,7 +221,7 @@ runs:
221221
fi
222222
- name: Upload visual test artifacts
223223
if: always() && inputs.uploadVisualTestArtifacts == 'true'
224-
uses: actions/upload-artifact@v4
224+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
225225
with:
226226
name: visual-test-diffs-${{ fromJson(steps.load-config.outputs.config).platformId }}
227227
path: |
@@ -230,21 +230,21 @@ runs:
230230
if-no-files-found: ignore
231231
- name: Save AVD cache
232232
if: ${{ always() && fromJson(steps.load-config.outputs.config).platformId == 'android' && fromJson(steps.load-config.outputs.config).config.device.type == 'emulator' && fromJson(steps.load-config.outputs.config).action.avdCachingEnabled && steps.avd-cache.outputs.cache-hit != 'true' }}
233-
uses: actions/cache/save@v4
233+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
234234
with:
235235
path: |
236236
~/.android/avd
237237
~/.android/adb*
238238
key: ${{ steps.avd-key.outputs.key }}
239239
- name: Save Harness cache
240240
if: ${{ always() && fromJson(steps.load-config.outputs.config).platformId == 'ios' && steps.cache-harness-restore.outputs.cache-hit != 'true' }}
241-
uses: actions/cache/save@v4
241+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
242242
with:
243243
path: ${{ steps.load-config.outputs.projectRoot }}/.harness/cache
244244
key: ${{ steps.cache-harness-restore.outputs.cache-primary-key }}
245245
- name: Upload crash report artifacts
246246
if: always()
247-
uses: actions/upload-artifact@v4
247+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
248248
with:
249249
name: harness-crash-reports-${{ fromJson(steps.load-config.outputs.config).platformId }}
250250
path: ${{ steps.load-config.outputs.projectRoot }}/.harness/crash-reports/**/*

actions/android/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ runs:
9898
echo "key=$CACHE_KEY" >> $GITHUB_OUTPUT
9999
- name: Restore AVD cache
100100
if: ${{ fromJson(steps.load-config.outputs.config).config.device.type == 'emulator' && fromJson(steps.load-config.outputs.config).action.avdCachingEnabled }}
101-
uses: actions/cache/restore@v4
101+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
102102
id: avd-cache
103103
with:
104104
path: |
@@ -150,7 +150,7 @@ runs:
150150
fi
151151
- name: Upload visual test artifacts
152152
if: always() && inputs.uploadVisualTestArtifacts == 'true'
153-
uses: actions/upload-artifact@v4
153+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
154154
with:
155155
name: visual-test-diffs-android
156156
path: |
@@ -159,15 +159,15 @@ runs:
159159
if-no-files-found: ignore
160160
- name: Save AVD cache
161161
if: ${{ always() && fromJson(steps.load-config.outputs.config).config.device.type == 'emulator' && fromJson(steps.load-config.outputs.config).action.avdCachingEnabled && steps.avd-cache.outputs.cache-hit != 'true' }}
162-
uses: actions/cache/save@v4
162+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
163163
with:
164164
path: |
165165
~/.android/avd
166166
~/.android/adb*
167167
key: ${{ steps.avd-key.outputs.key }}
168168
- name: Upload crash report artifacts
169169
if: always()
170-
uses: actions/upload-artifact@v4
170+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
171171
with:
172172
name: harness-crash-reports-android
173173
path: ${{ inputs.projectRoot }}/.harness/crash-reports/**/*

actions/ios/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ runs:
8787
fi
8888
- name: Upload visual test artifacts
8989
if: always() && inputs.uploadVisualTestArtifacts == 'true'
90-
uses: actions/upload-artifact@v4
90+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
9191
with:
9292
name: visual-test-diffs-ios
9393
path: |
@@ -96,7 +96,7 @@ runs:
9696
if-no-files-found: ignore
9797
- name: Upload crash report artifacts
9898
if: always()
99-
uses: actions/upload-artifact@v4
99+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
100100
with:
101101
name: harness-crash-reports-ios
102102
path: ${{ inputs.projectRoot }}/.harness/crash-reports/**/*

actions/shared/index.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4427,7 +4427,7 @@ var ConfigSchema = external_exports.object({
44274427
coverage: external_exports.object({
44284428
root: external_exports.string().optional().describe(`Root directory for coverage instrumentation in monorepo setups. Specifies the directory from which coverage data should be collected. Use ".." for create-react-native-library projects where tests run from example/ but source files are in parent directory. Passed to babel-plugin-istanbul's cwd option.`)
44294429
}).optional(),
4430-
forwardClientLogs: external_exports.boolean().optional().default(false).describe("Enable forwarding of console.log, console.warn, console.error, and other console method calls from the React Native app to the terminal. When enabled, all console output from your app will be displayed in the test runner terminal with styled level indicators (log, warn, error)."),
4430+
forwardClientLogs: external_exports.boolean().optional().default(false).describe("Enable forwarding of console.log, console.warn, console.error, and other console method calls from the React Native app during the active test run. When enabled, app console output is attached to the active test result's console output."),
44314431
// Deprecated property - used for migration detection
44324432
include: external_exports.array(external_exports.string()).optional()
44334433
}).refine((config) => {

actions/web/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ runs:
115115
fi
116116
- name: Upload visual test artifacts
117117
if: always() && inputs.uploadVisualTestArtifacts == 'true'
118-
uses: actions/upload-artifact@v4
118+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
119119
with:
120120
name: visual-test-diffs-chromium
121121
path: |
@@ -124,7 +124,7 @@ runs:
124124
if-no-files-found: ignore
125125
- name: Upload crash report artifacts
126126
if: always()
127-
uses: actions/upload-artifact@v4
127+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
128128
with:
129129
name: harness-crash-reports-web
130130
path: ${{ inputs.projectRoot }}/.harness/crash-reports/**/*

packages/cli/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default [
99
'error',
1010
{
1111
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}'],
12-
ignoredDependencies: ['@react-native-harness/bridge', '@react-native-harness/platform-android', '@react-native-harness/platform-apple', '@react-native-harness/platform-web'],
12+
ignoredDependencies: ['@react-native-harness/bridge', '@react-native-harness/platform-android', '@react-native-harness/platform-apple', '@react-native-harness/platform-web', 'vitest'],
1313
},
1414
],
1515
},

packages/platform-android/eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default [
88
'@nx/dependency-checks': [
99
'error',
1010
{
11+
ignoredDependencies: ['vite', 'vitest'],
1112
ignoredFiles: [
1213
'{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}',
1314
'{projectRoot}/src/**/__tests__/**',

packages/platform-android/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@react-native-harness/config": "workspace:*",
2020
"@react-native-harness/platforms": "workspace:*",
2121
"@react-native-harness/tools": "workspace:*",
22+
"vite": "^7.2.2",
2223
"zod": "^3.25.67",
2324
"tslib": "^2.3.0"
2425
},

0 commit comments

Comments
 (0)