@react-native-harness/jest 1.1.0 → 1.2.0
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__/bridge.test.d.ts +2 -0
- package/dist/__tests__/bridge.test.d.ts.map +1 -0
- package/dist/__tests__/bridge.test.js +142 -0
- package/dist/__tests__/client-log-handler.test.js +116 -72
- package/dist/__tests__/crash-monitor.test.d.ts +2 -0
- package/dist/__tests__/crash-monitor.test.d.ts.map +1 -0
- package/dist/__tests__/crash-monitor.test.js +212 -0
- package/dist/__tests__/execute-run.test.d.ts +2 -0
- package/dist/__tests__/execute-run.test.d.ts.map +1 -0
- package/dist/__tests__/execute-run.test.js +229 -0
- package/dist/__tests__/harness.test.js +35 -0
- package/dist/__tests__/hook-queue.test.d.ts +2 -0
- package/dist/__tests__/hook-queue.test.d.ts.map +1 -0
- package/dist/__tests__/hook-queue.test.js +56 -0
- package/dist/__tests__/index.test.js +94 -37
- package/dist/__tests__/resource-lock.test.js +24 -24
- 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/client-log-handler.d.ts +10 -11
- package/dist/client-log-handler.d.ts.map +1 -1
- package/dist/client-log-handler.js +36 -58
- package/dist/crash-monitor.d.ts +23 -0
- package/dist/crash-monitor.d.ts.map +1 -0
- package/dist/crash-monitor.js +176 -0
- 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/execute-run.d.ts +4 -0
- package/dist/execute-run.d.ts.map +1 -0
- package/dist/execute-run.js +151 -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-session.d.ts +34 -0
- package/dist/harness-session.d.ts.map +1 -0
- package/dist/harness-session.js +523 -0
- package/dist/harness.d.ts.map +1 -1
- package/dist/harness.js +6 -1
- package/dist/hook-queue.d.ts +6 -0
- package/dist/hook-queue.d.ts.map +1 -0
- package/dist/hook-queue.js +18 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -230
- 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 +1 -0
- package/dist/logs.d.ts.map +1 -1
- package/dist/logs.js +3 -0
- package/dist/resource-lock.d.ts +0 -1
- package/dist/resource-lock.d.ts.map +1 -1
- package/dist/resource-lock.js +1 -1
- package/dist/run.d.ts +2 -2
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +3 -3
- 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 -8
- package/src/__tests__/bridge.test.ts +184 -0
- package/src/__tests__/client-log-handler.test.ts +117 -81
- package/src/__tests__/crash-monitor.test.ts +288 -0
- package/src/__tests__/execute-run.test.ts +325 -0
- package/src/__tests__/hook-queue.test.ts +77 -0
- package/src/__tests__/index.test.ts +135 -55
- package/src/__tests__/resource-lock.test.ts +29 -42
- package/src/client-log-handler.ts +48 -64
- package/src/crash-monitor.ts +248 -0
- package/src/execute-run.ts +199 -0
- package/src/harness-session.ts +734 -0
- package/src/hook-queue.ts +26 -0
- package/src/index.ts +17 -330
- package/src/logs.ts +4 -0
- package/src/resource-lock.ts +1 -1
- package/src/run.ts +5 -5
- package/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/crash-supervisor.test.ts +0 -200
- package/src/__tests__/harness-cache.test.ts +0 -74
- package/src/__tests__/harness.test.ts +0 -870
- package/src/crash-supervisor.ts +0 -321
- package/src/env.d.ts +0 -9
- package/src/harness.ts +0 -864
- package/src/setup.ts +0 -127
- package/src/teardown.ts +0 -14
package/src/setup.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getConfig,
|
|
3
|
-
type Config as HarnessConfig,
|
|
4
|
-
ConfigSchema,
|
|
5
|
-
} from '@react-native-harness/config';
|
|
6
|
-
import type { Config as JestConfig } from 'jest-runner';
|
|
7
|
-
import { getHarness } from './harness.js';
|
|
8
|
-
import { preRunMessage } from 'jest-util';
|
|
9
|
-
import { getAdditionalCliArgs, HarnessCliArgs } from './cli-args.js';
|
|
10
|
-
import { logTestEnvironmentReady, logTestRunHeader } from './logs.js';
|
|
11
|
-
import { NoRunnerSpecifiedError, RunnerNotFoundError } from './errors.js';
|
|
12
|
-
import { HarnessPlatform } from '@react-native-harness/platforms';
|
|
13
|
-
import { logger } from '@react-native-harness/tools';
|
|
14
|
-
import { createActionHooksPlugin } from './action-hooks.js';
|
|
15
|
-
|
|
16
|
-
const setupLogger = logger.child('setup');
|
|
17
|
-
|
|
18
|
-
const getHarnessConfig = async (
|
|
19
|
-
globalConfig: JestConfig.GlobalConfig
|
|
20
|
-
): Promise<HarnessConfig> => {
|
|
21
|
-
const projectRoot = globalConfig.rootDir;
|
|
22
|
-
setupLogger.debug('loading Harness config from %s', projectRoot);
|
|
23
|
-
const { config: harnessConfig } = await getConfig(projectRoot);
|
|
24
|
-
setupLogger.debug('loaded Harness config');
|
|
25
|
-
return harnessConfig;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const getHarnessRunner = (
|
|
29
|
-
config: HarnessConfig,
|
|
30
|
-
cliArgs: HarnessCliArgs
|
|
31
|
-
): HarnessPlatform => {
|
|
32
|
-
const selectedRunnerName = cliArgs.harnessRunner ?? config.defaultRunner;
|
|
33
|
-
|
|
34
|
-
if (!selectedRunnerName) {
|
|
35
|
-
throw new NoRunnerSpecifiedError();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const runner = config.runners.find(
|
|
39
|
-
(runner) => runner.name === selectedRunnerName
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
if (!runner) {
|
|
43
|
-
throw new RunnerNotFoundError(selectedRunnerName);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
setupLogger.debug('selected runner %s (%s)', runner.name, runner.platformId);
|
|
47
|
-
return runner;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const setup = async (globalConfig: JestConfig.GlobalConfig) => {
|
|
51
|
-
preRunMessage.remove(process.stderr);
|
|
52
|
-
let harnessConfig =
|
|
53
|
-
global.HARNESS_CONFIG ?? (await getHarnessConfig(globalConfig));
|
|
54
|
-
|
|
55
|
-
if (global.HARNESS) {
|
|
56
|
-
// Do not setup again if HARNESS is already initialized
|
|
57
|
-
// This is useful when running tests in watch mode
|
|
58
|
-
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Gracefully dispose the Harness when the process exits.
|
|
63
|
-
process.on('exit', async () => {
|
|
64
|
-
await global.HARNESS.dispose();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const cliArgs = getAdditionalCliArgs();
|
|
68
|
-
|
|
69
|
-
if (cliArgs.metroPort != null) {
|
|
70
|
-
setupLogger.debug(
|
|
71
|
-
'applying CLI metro port override: %d',
|
|
72
|
-
cliArgs.metroPort
|
|
73
|
-
);
|
|
74
|
-
harnessConfig = ConfigSchema.parse({
|
|
75
|
-
...harnessConfig,
|
|
76
|
-
metroPort: cliArgs.metroPort,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (process.env.PRE_RUN_HOOK || process.env.AFTER_RUN_HOOK) {
|
|
81
|
-
harnessConfig = ConfigSchema.parse({
|
|
82
|
-
...harnessConfig,
|
|
83
|
-
plugins: [...(harnessConfig.plugins ?? []), createActionHooksPlugin()],
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const selectedRunner = getHarnessRunner(harnessConfig, cliArgs);
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
harnessConfig.webSocketPort != null &&
|
|
91
|
-
harnessConfig.webSocketPort !== harnessConfig.metroPort
|
|
92
|
-
) {
|
|
93
|
-
logger.warn(
|
|
94
|
-
`Config option "webSocketPort" is deprecated and ignored. Harness now uses metroPort (${harnessConfig.metroPort}) for bridge traffic.`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (globalConfig.collectCoverage) {
|
|
99
|
-
// This is going to be used by @react-native-harness/babel-preset
|
|
100
|
-
// to enable instrumentation of test files.
|
|
101
|
-
process.env.RN_HARNESS_COLLECT_COVERAGE = 'true';
|
|
102
|
-
|
|
103
|
-
if (harnessConfig.coverage?.root) {
|
|
104
|
-
process.env.RN_HARNESS_COVERAGE_ROOT = harnessConfig.coverage.root;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
setupLogger.debug('coverage enabled for this run');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (harnessConfig.disableViewFlattening) {
|
|
111
|
-
process.env.RN_HARNESS_VIEW_FLATTENING = 'false';
|
|
112
|
-
setupLogger.debug('view flattening disabled for runtime');
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
logTestRunHeader(selectedRunner);
|
|
116
|
-
setupLogger.debug('creating Harness instance');
|
|
117
|
-
const harness = await getHarness(
|
|
118
|
-
harnessConfig,
|
|
119
|
-
selectedRunner,
|
|
120
|
-
globalConfig.rootDir
|
|
121
|
-
);
|
|
122
|
-
logTestEnvironmentReady(selectedRunner);
|
|
123
|
-
setupLogger.debug('Harness instance is ready');
|
|
124
|
-
|
|
125
|
-
global.HARNESS_CONFIG = harness.config;
|
|
126
|
-
global.HARNESS = harness;
|
|
127
|
-
};
|
package/src/teardown.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Config as JestConfig } from 'jest-runner';
|
|
2
|
-
|
|
3
|
-
export const teardown = async (globalConfig: JestConfig.GlobalConfig) => {
|
|
4
|
-
const isWatchMode = globalConfig.watch || globalConfig.watchAll;
|
|
5
|
-
|
|
6
|
-
if (isWatchMode) {
|
|
7
|
-
// In watch mode, we don't want to dispose the Harness.
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (global.HARNESS) {
|
|
12
|
-
await global.HARNESS.dispose();
|
|
13
|
-
}
|
|
14
|
-
};
|