@react-native-harness/jest 1.1.0-rc.2 → 1.1.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/errors.test.js +6 -1
- package/dist/__tests__/harness-cache.test.js +1 -1
- package/dist/__tests__/harness.test.js +147 -3
- package/dist/__tests__/resource-lock.test.d.ts +2 -0
- package/dist/__tests__/resource-lock.test.d.ts.map +1 -0
- package/dist/__tests__/resource-lock.test.js +103 -0
- package/dist/action-hooks.d.ts +9 -0
- package/dist/action-hooks.d.ts.map +1 -0
- package/dist/action-hooks.js +36 -0
- package/dist/cli-args.test.d.ts +2 -0
- package/dist/cli-args.test.d.ts.map +1 -0
- package/dist/cli-args.test.js +1 -0
- package/dist/crash-monitor.d.ts +16 -0
- package/dist/crash-monitor.d.ts.map +1 -0
- package/dist/crash-monitor.js +75 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +9 -2
- package/dist/event-mapper.d.ts +16 -0
- package/dist/event-mapper.d.ts.map +1 -0
- package/dist/event-mapper.js +120 -0
- package/dist/global-setup.d.ts +3 -0
- package/dist/global-setup.d.ts.map +1 -0
- package/dist/global-setup.js +60 -0
- package/dist/global-teardown.d.ts +3 -0
- package/dist/global-teardown.d.ts.map +1 -0
- package/dist/global-teardown.js +11 -0
- package/dist/harness-reporter.d.ts +8 -0
- package/dist/harness-reporter.d.ts.map +1 -0
- package/dist/harness-reporter.js +12 -0
- package/dist/harness.d.ts.map +1 -1
- package/dist/harness.js +478 -386
- package/dist/jest-options.d.ts +2 -0
- package/dist/jest-options.d.ts.map +1 -0
- package/dist/jest-options.js +1 -0
- package/dist/logs.d.ts +3 -0
- package/dist/logs.d.ts.map +1 -1
- package/dist/logs.js +9 -0
- package/dist/resource-lock.d.ts +25 -0
- package/dist/resource-lock.d.ts.map +1 -0
- package/dist/resource-lock.js +278 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +11 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +7 -7
- package/src/__tests__/errors.test.ts +18 -6
- package/src/__tests__/harness-cache.test.ts +2 -2
- package/src/__tests__/harness.test.ts +254 -19
- package/src/__tests__/resource-lock.test.ts +138 -0
- package/src/action-hooks.ts +66 -0
- package/src/errors.ts +10 -4
- package/src/harness.ts +585 -445
- package/src/logs.ts +13 -3
- package/src/resource-lock.ts +450 -0
- package/src/setup.ts +21 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
definePlugin,
|
|
3
|
+
type HarnessPlugin,
|
|
4
|
+
} from '@react-native-harness/plugins';
|
|
5
|
+
import type { Config as HarnessConfig } from '@react-native-harness/config';
|
|
6
|
+
import type { HarnessPlatform } from '@react-native-harness/platforms';
|
|
7
|
+
import { spawn } from '@react-native-harness/tools';
|
|
8
|
+
|
|
9
|
+
type ActionHookState = {
|
|
10
|
+
_unused?: never;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const getInlineHookScript = (
|
|
14
|
+
name: 'PRE_RUN_HOOK' | 'AFTER_RUN_HOOK'
|
|
15
|
+
): string | null => {
|
|
16
|
+
const value = process.env[name]?.trim();
|
|
17
|
+
|
|
18
|
+
return value ? value : null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const runInlineHook = async (script: string): Promise<void> => {
|
|
22
|
+
const env = Object.fromEntries(
|
|
23
|
+
Object.entries(process.env).filter(
|
|
24
|
+
(entry): entry is [string, string] => entry[1] != null
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
await spawn('bash', ['-lc', script], {
|
|
29
|
+
env,
|
|
30
|
+
cwd: process.env.HARNESS_PROJECT_ROOT,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const createActionHooksPlugin = (): HarnessPlugin<
|
|
35
|
+
ActionHookState,
|
|
36
|
+
HarnessConfig,
|
|
37
|
+
HarnessPlatform
|
|
38
|
+
> =>
|
|
39
|
+
definePlugin({
|
|
40
|
+
name: 'github-action-hooks',
|
|
41
|
+
createState: () => ({}),
|
|
42
|
+
hooks: {
|
|
43
|
+
harness: {
|
|
44
|
+
beforeRun: async () => {
|
|
45
|
+
const script = getInlineHookScript('PRE_RUN_HOOK');
|
|
46
|
+
|
|
47
|
+
if (!script) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await runInlineHook(script);
|
|
52
|
+
},
|
|
53
|
+
afterRun: async (ctx) => {
|
|
54
|
+
const script = getInlineHookScript('AFTER_RUN_HOOK');
|
|
55
|
+
|
|
56
|
+
if (!script) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
process.env.HARNESS_EXIT_CODE = ctx.status === 'passed' ? '0' : '1';
|
|
61
|
+
|
|
62
|
+
await runInlineHook(script);
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
package/src/errors.ts
CHANGED
|
@@ -27,6 +27,15 @@ export class InitializationTimeoutError extends HarnessError {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export class PlatformReadyTimeoutError extends HarnessError {
|
|
31
|
+
constructor(public readonly timeout: number) {
|
|
32
|
+
super(
|
|
33
|
+
`The platform did not become ready within ${timeout}ms. Increase "platformReadyTimeout" if your device, simulator, or emulator needs more time to start.`
|
|
34
|
+
);
|
|
35
|
+
this.name = 'PlatformReadyTimeoutError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
export type NativeCrashPhase = 'startup' | 'execution';
|
|
31
40
|
|
|
32
41
|
export type NativeCrashDetails = AppCrashDetails & {
|
|
@@ -51,10 +60,7 @@ const buildNativeCrashMessage = ({
|
|
|
51
60
|
const hasCrashBlock = summary?.includes('\n') ?? false;
|
|
52
61
|
const shouldRenderSummary =
|
|
53
62
|
Boolean(summary) &&
|
|
54
|
-
!(
|
|
55
|
-
!hasCrashBlock &&
|
|
56
|
-
artifactType === 'ios-crash-report'
|
|
57
|
-
);
|
|
63
|
+
!(!hasCrashBlock && artifactType === 'ios-crash-report');
|
|
58
64
|
|
|
59
65
|
if (shouldRenderSummary && summary) {
|
|
60
66
|
lines.push('');
|