react-native-harness 1.0.0-alpha.1 → 1.0.0-alpha.10
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/README.md +2 -2
- package/bin.js +1 -1
- package/dist/babel.d.ts +2 -0
- package/dist/babel.d.ts.map +1 -0
- package/dist/babel.js +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -37
- package/dist/metro.d.ts +2 -0
- package/dist/metro.d.ts.map +1 -0
- package/dist/metro.js +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/eslint.config.mjs +1 -1
- package/package.json +31 -12
- package/src/babel.ts +1 -0
- package/src/index.ts +1 -52
- package/src/metro.ts +1 -0
- package/tsconfig.json +9 -3
- package/tsconfig.lib.json +8 -14
- package/types/index.d.ts +1 -0
- package/dist/bundlers/metro.d.ts +0 -5
- package/dist/bundlers/metro.d.ts.map +0 -1
- package/dist/bundlers/metro.js +0 -52
- package/dist/bundlers/webpack.d.ts +0 -2
- package/dist/bundlers/webpack.d.ts.map +0 -1
- package/dist/bundlers/webpack.js +0 -49
- package/dist/commands/test.d.ts +0 -2
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/commands/test.js +0 -111
- package/dist/errors/appNotInstalledError.d.ts +0 -7
- package/dist/errors/appNotInstalledError.d.ts.map +0 -1
- package/dist/errors/appNotInstalledError.js +0 -12
- package/dist/errors/bridgeTimeoutError.d.ts +0 -7
- package/dist/errors/bridgeTimeoutError.d.ts.map +0 -1
- package/dist/errors/bridgeTimeoutError.js +0 -12
- package/dist/errors/errorHandler.d.ts +0 -2
- package/dist/errors/errorHandler.d.ts.map +0 -1
- package/dist/errors/errorHandler.js +0 -138
- package/dist/errors/errors.d.ts +0 -41
- package/dist/errors/errors.d.ts.map +0 -1
- package/dist/errors/errors.js +0 -83
- package/dist/platforms/android/build.d.ts +0 -5
- package/dist/platforms/android/build.d.ts.map +0 -1
- package/dist/platforms/android/build.js +0 -29
- package/dist/platforms/android/device.d.ts +0 -5
- package/dist/platforms/android/device.d.ts.map +0 -1
- package/dist/platforms/android/device.js +0 -36
- package/dist/platforms/android/emulator.d.ts +0 -11
- package/dist/platforms/android/emulator.d.ts.map +0 -1
- package/dist/platforms/android/emulator.js +0 -110
- package/dist/platforms/android/index.d.ts +0 -4
- package/dist/platforms/android/index.d.ts.map +0 -1
- package/dist/platforms/android/index.js +0 -56
- package/dist/platforms/ios/build.d.ts +0 -7
- package/dist/platforms/ios/build.d.ts.map +0 -1
- package/dist/platforms/ios/build.js +0 -51
- package/dist/platforms/ios/device.d.ts +0 -7
- package/dist/platforms/ios/device.d.ts.map +0 -1
- package/dist/platforms/ios/device.js +0 -51
- package/dist/platforms/ios/index.d.ts +0 -4
- package/dist/platforms/ios/index.d.ts.map +0 -1
- package/dist/platforms/ios/index.js +0 -38
- package/dist/platforms/ios/simulator.d.ts +0 -11
- package/dist/platforms/ios/simulator.d.ts.map +0 -1
- package/dist/platforms/ios/simulator.js +0 -133
- package/dist/platforms/platform-adapter.d.ts +0 -10
- package/dist/platforms/platform-adapter.d.ts.map +0 -1
- package/dist/platforms/platform-adapter.js +0 -1
- package/dist/platforms/platform-registry.d.ts +0 -3
- package/dist/platforms/platform-registry.d.ts.map +0 -1
- package/dist/platforms/platform-registry.js +0 -19
- package/dist/platforms/web/index.d.ts +0 -4
- package/dist/platforms/web/index.d.ts.map +0 -1
- package/dist/platforms/web/index.js +0 -73
- package/dist/process.d.ts +0 -3
- package/dist/process.d.ts.map +0 -1
- package/dist/process.js +0 -28
- package/dist/reporters/default-reporter.d.ts +0 -3
- package/dist/reporters/default-reporter.d.ts.map +0 -1
- package/dist/reporters/default-reporter.js +0 -116
- package/dist/reporters/junit-reporter.d.ts +0 -3
- package/dist/reporters/junit-reporter.d.ts.map +0 -1
- package/dist/reporters/junit-reporter.js +0 -119
- package/dist/reporters/live-reporter.d.ts +0 -20
- package/dist/reporters/live-reporter.d.ts.map +0 -1
- package/dist/reporters/live-reporter.js +0 -176
- package/dist/src/reporters/default-reporter.js +0 -135
- package/dist/test-reporter-demo.js +0 -95
- package/dist/utils.d.ts +0 -5
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -11
- package/src/bundlers/metro.ts +0 -79
- package/src/commands/test.ts +0 -189
- package/src/errors/errorHandler.ts +0 -184
- package/src/errors/errors.ts +0 -109
- package/src/platforms/android/build.ts +0 -48
- package/src/platforms/android/device.ts +0 -48
- package/src/platforms/android/emulator.ts +0 -139
- package/src/platforms/android/index.ts +0 -87
- package/src/platforms/ios/build.ts +0 -76
- package/src/platforms/ios/device.ts +0 -76
- package/src/platforms/ios/index.ts +0 -55
- package/src/platforms/ios/simulator.ts +0 -177
- package/src/platforms/platform-adapter.ts +0 -11
- package/src/platforms/platform-registry.ts +0 -24
- package/src/platforms/web/index.ts +0 -95
- package/src/process.ts +0 -33
- package/src/reporters/default-reporter.ts +0 -149
- package/src/reporters/junit-reporter.ts +0 -179
- package/src/utils.ts +0 -12
- package/tsconfig.tsbuildinfo +0 -1
package/dist/commands/test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAqJA,eAAO,MAAM,WAAW,GACtB,aAAa,MAAM,EACnB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CAoCd,CAAC"}
|
package/dist/commands/test.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { getBridgeServer, } from '@react-native-harness/bridge/server';
|
|
2
|
-
import { getConfig, } from '@react-native-harness/config';
|
|
3
|
-
import { getPlatformAdapter } from '../platforms/platform-registry.js';
|
|
4
|
-
import { Glob } from 'glob';
|
|
5
|
-
import { defaultReporter } from '../reporters/default-reporter.js';
|
|
6
|
-
import { intro, logger, outro, spinner, progress, } from '@react-native-harness/tools';
|
|
7
|
-
import { BridgeTimeoutError } from '../errors/errors.js';
|
|
8
|
-
import { assert } from '../utils.js';
|
|
9
|
-
import { EnvironmentInitializationError, NoRunnerSpecifiedError, RpcClientError, RunnerNotFoundError, } from '../errors/errors.js';
|
|
10
|
-
const setupEnvironment = async (context) => {
|
|
11
|
-
const startSpinner = spinner();
|
|
12
|
-
const platform = context.runner.platform;
|
|
13
|
-
startSpinner.start(`Starting "${context.runner.name}" (${platform}) runner`);
|
|
14
|
-
const platformAdapter = await getPlatformAdapter(platform);
|
|
15
|
-
const serverBridge = await getBridgeServer({
|
|
16
|
-
port: 3001,
|
|
17
|
-
});
|
|
18
|
-
context.bridge = serverBridge;
|
|
19
|
-
const readyPromise = new Promise((resolve, reject) => {
|
|
20
|
-
const timeout = setTimeout(() => {
|
|
21
|
-
reject(new BridgeTimeoutError(context.config.bridgeTimeout, context.runner.name, platform));
|
|
22
|
-
}, context.config.bridgeTimeout);
|
|
23
|
-
serverBridge.once('ready', () => {
|
|
24
|
-
clearTimeout(timeout);
|
|
25
|
-
resolve();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
context.environment = await platformAdapter.getEnvironment(context.runner);
|
|
29
|
-
logger.debug('Waiting for bridge to be ready');
|
|
30
|
-
await readyPromise;
|
|
31
|
-
logger.debug('Bridge is ready');
|
|
32
|
-
if (!context.environment) {
|
|
33
|
-
throw new EnvironmentInitializationError('Failed to initialize environment', context.runner.name, platform, 'Platform adapter returned null environment');
|
|
34
|
-
}
|
|
35
|
-
startSpinner.stop(`"${context.runner.name}" (${platform}) runner started`);
|
|
36
|
-
};
|
|
37
|
-
const findTestFiles = async (context, pattern) => {
|
|
38
|
-
const discoverSpinner = spinner();
|
|
39
|
-
discoverSpinner.start('Discovering tests');
|
|
40
|
-
const globPattern = pattern || context.config.include;
|
|
41
|
-
const glob = new Glob(globPattern, {
|
|
42
|
-
cwd: process.cwd(),
|
|
43
|
-
});
|
|
44
|
-
context.testFiles = await glob.walk();
|
|
45
|
-
discoverSpinner.stop(`Found ${context.testFiles.length} test files`);
|
|
46
|
-
};
|
|
47
|
-
const runTests = async (context) => {
|
|
48
|
-
const { bridge, environment, testFiles } = context;
|
|
49
|
-
assert(bridge != null, 'Bridge not initialized');
|
|
50
|
-
assert(environment != null, 'Environment not initialized');
|
|
51
|
-
assert(testFiles != null, 'Test files not initialized');
|
|
52
|
-
let runSpinner = progress({ style: 'block' });
|
|
53
|
-
runSpinner.start('Running tests');
|
|
54
|
-
let shouldRestart = false;
|
|
55
|
-
for (const testFile of testFiles) {
|
|
56
|
-
if (shouldRestart) {
|
|
57
|
-
runSpinner = progress({ style: 'block' });
|
|
58
|
-
runSpinner.message(`Restarting environment for next test file`);
|
|
59
|
-
await new Promise((resolve) => {
|
|
60
|
-
bridge.once('ready', resolve);
|
|
61
|
-
environment.restart();
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
runSpinner.message(`Running tests in ${testFile}`);
|
|
65
|
-
const client = bridge.rpc.clients.at(-1);
|
|
66
|
-
if (!client) {
|
|
67
|
-
throw new RpcClientError('No RPC client available', 3001, 'No clients connected');
|
|
68
|
-
}
|
|
69
|
-
const result = await client.runTests(testFile);
|
|
70
|
-
context.results = [...(context.results ?? []), ...result.suites];
|
|
71
|
-
shouldRestart = true;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const cleanUp = async (context) => {
|
|
75
|
-
if (context.bridge) {
|
|
76
|
-
context.bridge.ws.close();
|
|
77
|
-
}
|
|
78
|
-
if (context.environment) {
|
|
79
|
-
await context.environment.dispose();
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
export const testCommand = async (runnerName, pattern) => {
|
|
83
|
-
intro('React Native Test Harness');
|
|
84
|
-
const config = await getConfig(process.cwd());
|
|
85
|
-
config.reporter = defaultReporter;
|
|
86
|
-
const selectedRunnerName = runnerName ?? config.defaultRunner;
|
|
87
|
-
if (!selectedRunnerName) {
|
|
88
|
-
throw new NoRunnerSpecifiedError(config.runners);
|
|
89
|
-
}
|
|
90
|
-
const runner = config.runners.find((r) => r.name === selectedRunnerName);
|
|
91
|
-
if (!runner) {
|
|
92
|
-
throw new RunnerNotFoundError(selectedRunnerName, config.runners);
|
|
93
|
-
}
|
|
94
|
-
const context = {
|
|
95
|
-
config,
|
|
96
|
-
runner,
|
|
97
|
-
testFiles: [],
|
|
98
|
-
results: [],
|
|
99
|
-
};
|
|
100
|
-
try {
|
|
101
|
-
await setupEnvironment(context);
|
|
102
|
-
await findTestFiles(context, pattern);
|
|
103
|
-
await runTests(context);
|
|
104
|
-
assert(context.results != null, 'Results not initialized');
|
|
105
|
-
config.reporter?.report(context.results);
|
|
106
|
-
outro('Test run completed successfully');
|
|
107
|
-
}
|
|
108
|
-
finally {
|
|
109
|
-
await cleanUp(context);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare class AppNotInstalledError extends Error {
|
|
2
|
-
readonly deviceName: string;
|
|
3
|
-
readonly bundleId: string;
|
|
4
|
-
readonly platform: 'ios' | 'android';
|
|
5
|
-
constructor(deviceName: string, bundleId: string, platform: 'ios' | 'android');
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=appNotInstalledError.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appNotInstalledError.d.ts","sourceRoot":"","sources":["../../src/errors/appNotInstalledError.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;aAEvB,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;aAChB,QAAQ,EAAE,KAAK,GAAG,SAAS;gBAF3B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,KAAK,GAAG,SAAS;CAKlD"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export class AppNotInstalledError extends Error {
|
|
2
|
-
deviceName;
|
|
3
|
-
bundleId;
|
|
4
|
-
platform;
|
|
5
|
-
constructor(deviceName, bundleId, platform) {
|
|
6
|
-
super(`App "${bundleId}" is not installed on ${platform === 'ios' ? 'simulator' : 'emulator'} "${deviceName}"`);
|
|
7
|
-
this.deviceName = deviceName;
|
|
8
|
-
this.bundleId = bundleId;
|
|
9
|
-
this.platform = platform;
|
|
10
|
-
this.name = 'AppNotInstalledError';
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare class BridgeTimeoutError extends Error {
|
|
2
|
-
readonly timeout: number;
|
|
3
|
-
readonly runnerName: string;
|
|
4
|
-
readonly platform: string;
|
|
5
|
-
constructor(timeout: number, runnerName: string, platform: string);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=bridgeTimeoutError.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bridgeTimeoutError.d.ts","sourceRoot":"","sources":["../../src/errors/bridgeTimeoutError.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;aAErB,OAAO,EAAE,MAAM;aACf,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;gBAFhB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM;CAKvC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export class BridgeTimeoutError extends Error {
|
|
2
|
-
timeout;
|
|
3
|
-
runnerName;
|
|
4
|
-
platform;
|
|
5
|
-
constructor(timeout, runnerName, platform) {
|
|
6
|
-
super(`Bridge connection timed out after ${timeout}ms while waiting for "${runnerName}" (${platform}) runner to be ready`);
|
|
7
|
-
this.timeout = timeout;
|
|
8
|
-
this.runnerName = runnerName;
|
|
9
|
-
this.platform = platform;
|
|
10
|
-
this.name = 'BridgeTimeoutError';
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/errors/errorHandler.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,IAuK5C,CAAC"}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { ConfigLoadError, ConfigNotFoundError, ConfigValidationError, } from '@react-native-harness/config';
|
|
2
|
-
import { AssertionError } from '../utils.js';
|
|
3
|
-
import { NoRunnerSpecifiedError, RunnerNotFoundError, EnvironmentInitializationError, TestExecutionError, RpcClientError, AppNotInstalledError, BridgeTimeoutError, } from './errors.js';
|
|
4
|
-
export const handleError = (error) => {
|
|
5
|
-
if (error instanceof AssertionError) {
|
|
6
|
-
console.error(`\n❌ Assertion Error`);
|
|
7
|
-
console.error(`\nError: ${error.message}`);
|
|
8
|
-
console.error(`\nPlease check your configuration and try again.`);
|
|
9
|
-
}
|
|
10
|
-
else if (error instanceof ConfigValidationError) {
|
|
11
|
-
console.error(`\n❌ Configuration Error`);
|
|
12
|
-
console.error(`\nFile: ${error.filePath}`);
|
|
13
|
-
console.error(`\nValidation errors:`);
|
|
14
|
-
error.validationErrors.forEach((err) => {
|
|
15
|
-
console.error(` • ${err}`);
|
|
16
|
-
});
|
|
17
|
-
console.error(`\nPlease fix the configuration errors and try again.`);
|
|
18
|
-
}
|
|
19
|
-
else if (error instanceof ConfigNotFoundError) {
|
|
20
|
-
console.error(`\n❌ Configuration Not Found`);
|
|
21
|
-
console.error(`\nCould not find 'rn-harness.config' in '${error.searchPath}' or any parent directories.`);
|
|
22
|
-
console.error(`\nSupported file extensions: .js, .mjs, .cjs, .json`);
|
|
23
|
-
console.error(`\nPlease create a configuration file or run from a directory that contains one.`);
|
|
24
|
-
}
|
|
25
|
-
else if (error instanceof ConfigLoadError) {
|
|
26
|
-
console.error(`\n❌ Configuration Load Error`);
|
|
27
|
-
console.error(`\nFile: ${error.filePath}`);
|
|
28
|
-
console.error(`Error: ${error.message}`);
|
|
29
|
-
if (error.cause) {
|
|
30
|
-
console.error(`\nCause: ${error.cause.message}`);
|
|
31
|
-
}
|
|
32
|
-
console.error(`\nPlease check your configuration file syntax and try again.`);
|
|
33
|
-
}
|
|
34
|
-
else if (error instanceof NoRunnerSpecifiedError) {
|
|
35
|
-
console.error('\n❌ No runner specified');
|
|
36
|
-
console.error('\nPlease specify a runner name or set a defaultRunner in your config.');
|
|
37
|
-
console.error('\nUsage: react-native-harness test [runner-name] [pattern]');
|
|
38
|
-
console.error('\nAvailable runners:');
|
|
39
|
-
error.availableRunners.forEach((r) => {
|
|
40
|
-
console.error(` • ${r.name} (${r.platform})`);
|
|
41
|
-
});
|
|
42
|
-
console.error('\nTo set a default runner, add "defaultRunner" to your config:');
|
|
43
|
-
console.error(' { "defaultRunner": "your-runner-name" }');
|
|
44
|
-
}
|
|
45
|
-
else if (error instanceof RunnerNotFoundError) {
|
|
46
|
-
console.error(`\n❌ Runner "${error.runnerName}" not found`);
|
|
47
|
-
console.error('\nAvailable runners:');
|
|
48
|
-
error.availableRunners.forEach((r) => {
|
|
49
|
-
console.error(` • ${r.name} (${r.platform})`);
|
|
50
|
-
});
|
|
51
|
-
console.error('\nTo add a new runner, update your rn-harness.config file.');
|
|
52
|
-
}
|
|
53
|
-
else if (error instanceof EnvironmentInitializationError) {
|
|
54
|
-
console.error(`\n❌ Environment Initialization Error`);
|
|
55
|
-
console.error(`\nRunner: ${error.runnerName} (${error.platform})`);
|
|
56
|
-
console.error(`\nError: ${error.message}`);
|
|
57
|
-
if (error.details) {
|
|
58
|
-
console.error(`\nDetails: ${error.details}`);
|
|
59
|
-
}
|
|
60
|
-
console.error(`\nTroubleshooting steps:`);
|
|
61
|
-
console.error(` • Verify that ${error.platform} development environment is properly set up`);
|
|
62
|
-
console.error(` • Check that the app is built and ready for testing`);
|
|
63
|
-
console.error(` • Ensure all required dependencies are installed`);
|
|
64
|
-
if (error.platform === 'ios') {
|
|
65
|
-
console.error(` • Verify Xcode and iOS Simulator are working correctly`);
|
|
66
|
-
}
|
|
67
|
-
else if (error.platform === 'android') {
|
|
68
|
-
console.error(` • Verify Android SDK and emulator are working correctly`);
|
|
69
|
-
}
|
|
70
|
-
console.error(`\nPlease check your environment configuration and try again.`);
|
|
71
|
-
}
|
|
72
|
-
else if (error instanceof TestExecutionError) {
|
|
73
|
-
console.error(`\n❌ Test Execution Error`);
|
|
74
|
-
console.error(`\nFile: ${error.testFile}`);
|
|
75
|
-
if (error.testSuite) {
|
|
76
|
-
console.error(`\nSuite: ${error.testSuite}`);
|
|
77
|
-
}
|
|
78
|
-
if (error.testName) {
|
|
79
|
-
console.error(`\nTest: ${error.testName}`);
|
|
80
|
-
}
|
|
81
|
-
console.error(`\nError: ${error.message}`);
|
|
82
|
-
console.error(`\nTroubleshooting steps:`);
|
|
83
|
-
console.error(` • Check the test file syntax and logic`);
|
|
84
|
-
console.error(` • Verify all test dependencies are available`);
|
|
85
|
-
console.error(` • Ensure the app is in the expected state for the test`);
|
|
86
|
-
console.error(` • Check device/emulator logs for additional error details`);
|
|
87
|
-
console.error(`\nPlease check your test file and try again.`);
|
|
88
|
-
}
|
|
89
|
-
else if (error instanceof RpcClientError) {
|
|
90
|
-
console.error(`\n❌ RPC Client Error`);
|
|
91
|
-
console.error(`\nError: ${error.message}`);
|
|
92
|
-
if (error.bridgePort) {
|
|
93
|
-
console.error(`\nBridge Port: ${error.bridgePort}`);
|
|
94
|
-
}
|
|
95
|
-
if (error.connectionStatus) {
|
|
96
|
-
console.error(`\nConnection Status: ${error.connectionStatus}`);
|
|
97
|
-
}
|
|
98
|
-
console.error(`\nTroubleshooting steps:`);
|
|
99
|
-
console.error(` • Verify the React Native app is running and connected`);
|
|
100
|
-
console.error(` • Check that the bridge port is not blocked by firewall`);
|
|
101
|
-
console.error(` • Ensure the app has the React Native Harness runtime integrated`);
|
|
102
|
-
console.error(` • Try restarting the app and test harness`);
|
|
103
|
-
console.error(`\nPlease check your bridge connection and try again.`);
|
|
104
|
-
}
|
|
105
|
-
else if (error instanceof AppNotInstalledError) {
|
|
106
|
-
console.error(`\n❌ App Not Installed`);
|
|
107
|
-
console.error(`\nThe app "${error.bundleId}" is not installed on ${error.platform === 'ios' ? 'simulator' : 'emulator'} "${error.deviceName}".`);
|
|
108
|
-
console.error(`\nTo resolve this issue:`);
|
|
109
|
-
if (error.platform === 'ios') {
|
|
110
|
-
console.error(` • Build and install the app: npx react-native run-ios --simulator="${error.deviceName}"`);
|
|
111
|
-
console.error(` • Or install from Xcode: Open ios/*.xcworkspace and run the project`);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
console.error(` • Build and install the app: npx react-native run-android`);
|
|
115
|
-
console.error(` • Or build manually: ./gradlew assembleDebug && adb install android/app/build/outputs/apk/debug/app-debug.apk`);
|
|
116
|
-
}
|
|
117
|
-
console.error(`\nPlease install the app and try running the tests again.`);
|
|
118
|
-
}
|
|
119
|
-
else if (error instanceof BridgeTimeoutError) {
|
|
120
|
-
console.error(`\n❌ Bridge Connection Timeout`);
|
|
121
|
-
console.error(`\nThe bridge connection timed out after ${error.timeout}ms while waiting for the "${error.runnerName}" (${error.platform}) runner to be ready.`);
|
|
122
|
-
console.error(`\nThis usually indicates that:`);
|
|
123
|
-
console.error(` • The React Native app failed to load or connect to the bridge`);
|
|
124
|
-
console.error(` • The app crashed during startup`);
|
|
125
|
-
console.error(` • Network connectivity issues between the app and the test harness`);
|
|
126
|
-
console.error(` • The app is taking longer than expected to initialize`);
|
|
127
|
-
console.error(`\nTo resolve this issue:`);
|
|
128
|
-
console.error(` • Check that the app is properly installed and can start normally`);
|
|
129
|
-
console.error(` • Verify that the app has the React Native Harness runtime integrated`);
|
|
130
|
-
console.error(` • Check device/emulator logs for any startup errors`);
|
|
131
|
-
console.error(` • Ensure the test harness bridge port (3001) is not blocked`);
|
|
132
|
-
console.error(`\nIf the app needs more time to start, consider increasing the timeout in the configuration.`);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
console.error(`\n❌ Unexpected Error`);
|
|
136
|
-
console.error(error);
|
|
137
|
-
}
|
|
138
|
-
};
|
package/dist/errors/errors.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { TestRunnerConfig } from '@react-native-harness/config';
|
|
2
|
-
export declare class NoRunnerSpecifiedError extends Error {
|
|
3
|
-
constructor(availableRunners: TestRunnerConfig[]);
|
|
4
|
-
availableRunners: TestRunnerConfig[];
|
|
5
|
-
}
|
|
6
|
-
export declare class RunnerNotFoundError extends Error {
|
|
7
|
-
constructor(runnerName: string, availableRunners: TestRunnerConfig[]);
|
|
8
|
-
runnerName: string;
|
|
9
|
-
availableRunners: TestRunnerConfig[];
|
|
10
|
-
}
|
|
11
|
-
export declare class EnvironmentInitializationError extends Error {
|
|
12
|
-
constructor(message: string, runnerName: string, platform: string, details?: string);
|
|
13
|
-
runnerName: string;
|
|
14
|
-
platform: string;
|
|
15
|
-
details?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare class TestExecutionError extends Error {
|
|
18
|
-
constructor(testFile: string, error: unknown, testSuite?: string, testName?: string);
|
|
19
|
-
testFile: string;
|
|
20
|
-
testSuite?: string;
|
|
21
|
-
testName?: string;
|
|
22
|
-
originalError: unknown;
|
|
23
|
-
}
|
|
24
|
-
export declare class RpcClientError extends Error {
|
|
25
|
-
constructor(message: string, bridgePort?: number, connectionStatus?: string);
|
|
26
|
-
bridgePort?: number;
|
|
27
|
-
connectionStatus?: string;
|
|
28
|
-
}
|
|
29
|
-
export declare class BridgeTimeoutError extends Error {
|
|
30
|
-
readonly timeout: number;
|
|
31
|
-
readonly runnerName: string;
|
|
32
|
-
readonly platform: string;
|
|
33
|
-
constructor(timeout: number, runnerName: string, platform: string);
|
|
34
|
-
}
|
|
35
|
-
export declare class AppNotInstalledError extends Error {
|
|
36
|
-
readonly deviceName: string;
|
|
37
|
-
readonly bundleId: string;
|
|
38
|
-
readonly platform: 'ios' | 'android';
|
|
39
|
-
constructor(deviceName: string, bundleId: string, platform: 'ios' | 'android');
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,gBAAgB,EAAE,gBAAgB,EAAE;IAKhD,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;CACtC;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE;IAMpE,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;CACtC;AAED,qBAAa,8BAA+B,SAAQ,KAAK;gBAErD,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM;IAUlB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAEzC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM;IAenB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM;IAS3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;aAEzB,OAAO,EAAE,MAAM;aACf,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;gBAFhB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM;CAOnC;AAED,qBAAa,oBAAqB,SAAQ,KAAK;aAE3B,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;aAChB,QAAQ,EAAE,KAAK,GAAG,SAAS;gBAF3B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,KAAK,GAAG,SAAS;CAS9C"}
|
package/dist/errors/errors.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
export class NoRunnerSpecifiedError extends Error {
|
|
2
|
-
constructor(availableRunners) {
|
|
3
|
-
super('No runner specified');
|
|
4
|
-
this.name = 'NoRunnerSpecifiedError';
|
|
5
|
-
this.availableRunners = availableRunners;
|
|
6
|
-
}
|
|
7
|
-
availableRunners;
|
|
8
|
-
}
|
|
9
|
-
export class RunnerNotFoundError extends Error {
|
|
10
|
-
constructor(runnerName, availableRunners) {
|
|
11
|
-
super(`Runner "${runnerName}" not found`);
|
|
12
|
-
this.name = 'RunnerNotFoundError';
|
|
13
|
-
this.runnerName = runnerName;
|
|
14
|
-
this.availableRunners = availableRunners;
|
|
15
|
-
}
|
|
16
|
-
runnerName;
|
|
17
|
-
availableRunners;
|
|
18
|
-
}
|
|
19
|
-
export class EnvironmentInitializationError extends Error {
|
|
20
|
-
constructor(message, runnerName, platform, details) {
|
|
21
|
-
super(`Failed to initialize environment for "${runnerName}" (${platform}): ${message}`);
|
|
22
|
-
this.name = 'EnvironmentInitializationError';
|
|
23
|
-
this.runnerName = runnerName;
|
|
24
|
-
this.platform = platform;
|
|
25
|
-
this.details = details;
|
|
26
|
-
}
|
|
27
|
-
runnerName;
|
|
28
|
-
platform;
|
|
29
|
-
details;
|
|
30
|
-
}
|
|
31
|
-
export class TestExecutionError extends Error {
|
|
32
|
-
constructor(testFile, error, testSuite, testName) {
|
|
33
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
34
|
-
const suiteInfo = testSuite ? ` in suite "${testSuite}"` : '';
|
|
35
|
-
const testInfo = testName ? ` test "${testName}"` : '';
|
|
36
|
-
super(`Test execution failed for ${testFile}${suiteInfo}${testInfo}: ${errorMessage}`);
|
|
37
|
-
this.name = 'TestExecutionError';
|
|
38
|
-
this.testFile = testFile;
|
|
39
|
-
this.testSuite = testSuite;
|
|
40
|
-
this.testName = testName;
|
|
41
|
-
this.originalError = error;
|
|
42
|
-
}
|
|
43
|
-
testFile;
|
|
44
|
-
testSuite;
|
|
45
|
-
testName;
|
|
46
|
-
originalError;
|
|
47
|
-
}
|
|
48
|
-
export class RpcClientError extends Error {
|
|
49
|
-
constructor(message, bridgePort, connectionStatus) {
|
|
50
|
-
const portInfo = bridgePort ? ` (port ${bridgePort})` : '';
|
|
51
|
-
const statusInfo = connectionStatus ? ` - Status: ${connectionStatus}` : '';
|
|
52
|
-
super(`RPC client error${portInfo}: ${message}${statusInfo}`);
|
|
53
|
-
this.name = 'RpcClientError';
|
|
54
|
-
this.bridgePort = bridgePort;
|
|
55
|
-
this.connectionStatus = connectionStatus;
|
|
56
|
-
}
|
|
57
|
-
bridgePort;
|
|
58
|
-
connectionStatus;
|
|
59
|
-
}
|
|
60
|
-
export class BridgeTimeoutError extends Error {
|
|
61
|
-
timeout;
|
|
62
|
-
runnerName;
|
|
63
|
-
platform;
|
|
64
|
-
constructor(timeout, runnerName, platform) {
|
|
65
|
-
super(`Bridge connection timed out after ${timeout}ms while waiting for "${runnerName}" (${platform}) runner to be ready`);
|
|
66
|
-
this.timeout = timeout;
|
|
67
|
-
this.runnerName = runnerName;
|
|
68
|
-
this.platform = platform;
|
|
69
|
-
this.name = 'BridgeTimeoutError';
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export class AppNotInstalledError extends Error {
|
|
73
|
-
deviceName;
|
|
74
|
-
bundleId;
|
|
75
|
-
platform;
|
|
76
|
-
constructor(deviceName, bundleId, platform) {
|
|
77
|
-
super(`App "${bundleId}" is not installed on ${platform === 'ios' ? 'simulator' : 'emulator'} "${deviceName}"`);
|
|
78
|
-
this.deviceName = deviceName;
|
|
79
|
-
this.bundleId = bundleId;
|
|
80
|
-
this.platform = platform;
|
|
81
|
-
this.name = 'AppNotInstalledError';
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const buildAndroidApp: () => Promise<void>;
|
|
2
|
-
export declare const installApp: (deviceId: string) => Promise<void>;
|
|
3
|
-
export declare const killApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
4
|
-
export declare const runApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
5
|
-
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/platforms/android/build.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,QAAa,OAAO,CAAC,IAAI,CAEpD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAiB/D,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CAWd,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { spawn } from '@react-native-harness/tools';
|
|
3
|
-
export const buildAndroidApp = async () => {
|
|
4
|
-
await spawn('react-native', ['build-android', '--tasks', 'assembleDebug']);
|
|
5
|
-
};
|
|
6
|
-
export const installApp = async (deviceId) => {
|
|
7
|
-
await spawn('adb', [
|
|
8
|
-
'-s',
|
|
9
|
-
deviceId,
|
|
10
|
-
'install',
|
|
11
|
-
'-r',
|
|
12
|
-
path.join(process.cwd(), 'android', 'app', 'build', 'outputs', 'apk', 'debug', 'app-debug.apk'),
|
|
13
|
-
]);
|
|
14
|
-
};
|
|
15
|
-
export const killApp = async (deviceId, bundleId) => {
|
|
16
|
-
await spawn('adb', ['-s', deviceId, 'shell', 'am', 'force-stop', bundleId]);
|
|
17
|
-
};
|
|
18
|
-
export const runApp = async (deviceId, bundleId) => {
|
|
19
|
-
await killApp(deviceId, bundleId);
|
|
20
|
-
await spawn('adb', [
|
|
21
|
-
'-s',
|
|
22
|
-
deviceId,
|
|
23
|
-
'shell',
|
|
24
|
-
'am',
|
|
25
|
-
'start',
|
|
26
|
-
'-n',
|
|
27
|
-
`${bundleId}/.MainActivity`,
|
|
28
|
-
]);
|
|
29
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const killApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
2
|
-
export declare const runApp: (deviceId: string, bundleId: string) => Promise<void>;
|
|
3
|
-
export declare const isAppInstalled: (deviceId: string, bundleId: string) => Promise<boolean>;
|
|
4
|
-
export declare const reversePort: (port: number) => Promise<void>;
|
|
5
|
-
//# sourceMappingURL=device.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../src/platforms/android/device.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,GAClB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CAWd,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,CAejB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CAE5D,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { spawn } from '@react-native-harness/tools';
|
|
2
|
-
export const killApp = async (deviceId, bundleId) => {
|
|
3
|
-
await spawn('adb', ['-s', deviceId, 'shell', 'am', 'force-stop', bundleId]);
|
|
4
|
-
};
|
|
5
|
-
export const runApp = async (deviceId, bundleId) => {
|
|
6
|
-
await killApp(deviceId, bundleId);
|
|
7
|
-
await spawn('adb', [
|
|
8
|
-
'-s',
|
|
9
|
-
deviceId,
|
|
10
|
-
'shell',
|
|
11
|
-
'am',
|
|
12
|
-
'start',
|
|
13
|
-
'-n',
|
|
14
|
-
`${bundleId}/.MainActivity`,
|
|
15
|
-
]);
|
|
16
|
-
};
|
|
17
|
-
export const isAppInstalled = async (deviceId, bundleId) => {
|
|
18
|
-
try {
|
|
19
|
-
const { stdout } = await spawn('adb', [
|
|
20
|
-
'-s',
|
|
21
|
-
deviceId,
|
|
22
|
-
'shell',
|
|
23
|
-
'pm',
|
|
24
|
-
'list',
|
|
25
|
-
'packages',
|
|
26
|
-
bundleId,
|
|
27
|
-
]);
|
|
28
|
-
return stdout.trim() !== '';
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
export const reversePort = async (port) => {
|
|
35
|
-
await spawn('adb', ['reverse', `tcp:${port}`, `tcp:${port}`]);
|
|
36
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ChildProcess } from 'node:child_process';
|
|
2
|
-
export type AndroidEmulatorStatus = 'running' | 'loading' | 'stopped';
|
|
3
|
-
export declare const getEmulatorNameFromId: (emulatorId: string) => Promise<string | null>;
|
|
4
|
-
export declare const getEmulatorDeviceId: (avdName: string) => Promise<string | null>;
|
|
5
|
-
export declare const getEmulatorStatus: (avdName: string) => Promise<AndroidEmulatorStatus>;
|
|
6
|
-
export declare const runEmulator: (name: string) => Promise<ChildProcess>;
|
|
7
|
-
export declare const stopEmulator: (avdName: string) => Promise<void>;
|
|
8
|
-
export declare const isAppInstalled: (emulatorId: string, bundleId: string) => Promise<boolean>;
|
|
9
|
-
export declare const reversePort: (port: number) => Promise<void>;
|
|
10
|
-
export declare const getEmulatorScreenshot: (emulatorId: string, name?: string) => Promise<string>;
|
|
11
|
-
//# sourceMappingURL=emulator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emulator.d.ts","sourceRoot":"","sources":["../../../src/platforms/android/emulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtE,eAAO,MAAM,qBAAqB,GAChC,YAAY,MAAM,KACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAQvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,KACd,OAAO,CAAC,MAAM,GAAG,IAAI,CAmBvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,KACd,OAAO,CAAC,qBAAqB,CAc/B,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,YAAY,CA2BpE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,IAAI,CAQhE,CAAC;AAOF,eAAO,MAAM,cAAc,GACzB,YAAY,MAAM,EAClB,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,CAOjB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CAE5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,YAAY,MAAM,EAClB,OAAM,MAGsB,KAC3B,OAAO,CAAC,MAAM,CAchB,CAAC"}
|