@react-native-harness/cli 1.0.0-canary.1764675030942 → 1.0.0-canary.1766225407244
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/bundlers/metro.d.ts +2 -2
- package/dist/bundlers/metro.d.ts.map +1 -1
- package/dist/bundlers/metro.js +24 -47
- package/dist/platforms/android/build.d.ts +2 -3
- package/dist/platforms/android/build.d.ts.map +1 -1
- package/dist/platforms/android/build.js +49 -24
- package/dist/platforms/android/emulator.d.ts +1 -0
- package/dist/platforms/android/emulator.d.ts.map +1 -1
- package/dist/platforms/android/emulator.js +132 -101
- package/dist/platforms/android/index.d.ts.map +1 -1
- package/dist/platforms/android/index.js +19 -23
- package/dist/platforms/ios/build.d.ts +7 -5
- package/dist/platforms/ios/build.d.ts.map +1 -1
- package/dist/platforms/ios/build.js +116 -41
- package/dist/platforms/ios/index.d.ts.map +1 -1
- package/dist/platforms/ios/index.js +32 -24
- package/dist/platforms/ios/simulator.d.ts +4 -4
- package/dist/platforms/ios/simulator.d.ts.map +1 -1
- package/dist/platforms/ios/simulator.js +131 -104
- package/dist/platforms/platform-adapter.d.ts +4 -2
- package/dist/platforms/platform-adapter.d.ts.map +1 -1
- package/dist/platforms/platform-registry.d.ts.map +1 -1
- package/dist/platforms/platform-registry.js +1 -5
- package/dist/platforms/web/index.d.ts +1 -3
- package/dist/platforms/web/index.d.ts.map +1 -1
- package/dist/platforms/web/index.js +50 -9
- package/dist/process.js +1 -1
- package/dist/reporters/default-reporter.d.ts.map +1 -1
- package/dist/reporters/default-reporter.js +17 -22
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/commands/test.d.ts +0 -3
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/commands/test.js +0 -140
- package/dist/discovery/index.d.ts +0 -3
- package/dist/discovery/index.d.ts.map +0 -1
- package/dist/discovery/index.js +0 -1
- package/dist/discovery/testDiscovery.d.ts +0 -11
- package/dist/discovery/testDiscovery.d.ts.map +0 -1
- package/dist/discovery/testDiscovery.js +0 -29
- 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 -152
- package/dist/errors/errors.d.ts +0 -45
- package/dist/errors/errors.d.ts.map +0 -1
- package/dist/errors/errors.js +0 -89
- package/dist/jest.d.ts +0 -2
- package/dist/jest.d.ts.map +0 -1
- package/dist/jest.js +0 -7
- 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/ios/device.d.ts +0 -11
- package/dist/platforms/ios/device.d.ts.map +0 -1
- package/dist/platforms/ios/device.js +0 -51
- package/dist/platforms/vega/build.d.ts +0 -23
- package/dist/platforms/vega/build.d.ts.map +0 -1
- package/dist/platforms/vega/build.js +0 -55
- package/dist/platforms/vega/device.d.ts +0 -57
- package/dist/platforms/vega/device.d.ts.map +0 -1
- package/dist/platforms/vega/device.js +0 -206
- package/dist/platforms/vega/index.d.ts +0 -4
- package/dist/platforms/vega/index.d.ts.map +0 -1
- package/dist/platforms/vega/index.js +0 -75
- 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/status-formatter.d.ts +0 -27
- package/dist/utils/status-formatter.d.ts.map +0 -1
- package/dist/utils/status-formatter.js +0 -54
- package/dist/utils.d.ts +0 -6
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -26
package/dist/commands/test.js
DELETED
|
@@ -1,140 +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 { intro, logger, outro, spinner } from '@react-native-harness/tools';
|
|
5
|
-
import { BridgeTimeoutError } from '../errors/errors.js';
|
|
6
|
-
import { assert } from '../utils.js';
|
|
7
|
-
import { EnvironmentInitializationError, NoRunnerSpecifiedError, RpcClientError, RunnerNotFoundError, } from '../errors/errors.js';
|
|
8
|
-
import { discoverTestFiles, } from '../discovery/index.js';
|
|
9
|
-
const setupEnvironment = async (context) => {
|
|
10
|
-
const startSpinner = spinner();
|
|
11
|
-
const platform = context.runner.platform;
|
|
12
|
-
startSpinner.start(`Starting "${context.runner.name}" (${platform}) runner`);
|
|
13
|
-
const platformAdapter = await getPlatformAdapter(platform);
|
|
14
|
-
const serverBridge = await getBridgeServer({
|
|
15
|
-
port: 3001,
|
|
16
|
-
});
|
|
17
|
-
context.bridge = serverBridge;
|
|
18
|
-
const readyPromise = new Promise((resolve, reject) => {
|
|
19
|
-
const timeout = setTimeout(() => {
|
|
20
|
-
reject(new BridgeTimeoutError(context.config.bridgeTimeout, context.runner.name, platform));
|
|
21
|
-
}, context.config.bridgeTimeout);
|
|
22
|
-
serverBridge.once('ready', () => {
|
|
23
|
-
clearTimeout(timeout);
|
|
24
|
-
resolve();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
context.environment = await platformAdapter.getEnvironment(context.runner);
|
|
28
|
-
logger.debug('Waiting for bridge to be ready');
|
|
29
|
-
await readyPromise;
|
|
30
|
-
logger.debug('Bridge is ready');
|
|
31
|
-
if (!context.environment) {
|
|
32
|
-
throw new EnvironmentInitializationError('Failed to initialize environment', context.runner.name, platform, 'Platform adapter returned null environment');
|
|
33
|
-
}
|
|
34
|
-
startSpinner.stop(`"${context.runner.name}" (${platform}) runner started`);
|
|
35
|
-
};
|
|
36
|
-
const findTestFiles = async (context, options = {}) => {
|
|
37
|
-
const discoverSpinner = spinner();
|
|
38
|
-
discoverSpinner.start('Discovering tests');
|
|
39
|
-
context.testFiles = await discoverTestFiles(context.projectRoot, context.config.include, options);
|
|
40
|
-
discoverSpinner.stop(`Found ${context.testFiles.length} test files`);
|
|
41
|
-
};
|
|
42
|
-
const runTests = async (context, options = {}) => {
|
|
43
|
-
const { bridge, environment, testFiles, config } = context;
|
|
44
|
-
assert(bridge != null, 'Bridge not initialized');
|
|
45
|
-
assert(environment != null, 'Environment not initialized');
|
|
46
|
-
assert(testFiles != null, 'Test files not initialized');
|
|
47
|
-
let runSpinner = spinner();
|
|
48
|
-
runSpinner.start('Running tests');
|
|
49
|
-
let shouldRestart = false;
|
|
50
|
-
for (const testFile of testFiles) {
|
|
51
|
-
if (shouldRestart) {
|
|
52
|
-
runSpinner = spinner();
|
|
53
|
-
runSpinner.start(`Restarting environment for next test file`);
|
|
54
|
-
await new Promise((resolve) => {
|
|
55
|
-
bridge.once('ready', resolve);
|
|
56
|
-
environment.restart();
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
runSpinner.message(`Running tests in ${testFile}`);
|
|
60
|
-
const client = bridge.rpc.clients.at(-1);
|
|
61
|
-
if (!client) {
|
|
62
|
-
throw new RpcClientError('No RPC client available', 3001, 'No clients connected');
|
|
63
|
-
}
|
|
64
|
-
// Pass only testNamePattern to runtime (file filtering already done)
|
|
65
|
-
const executionOptions = {
|
|
66
|
-
testNamePattern: options.testNamePattern,
|
|
67
|
-
};
|
|
68
|
-
const result = await client.runTests(testFile, executionOptions);
|
|
69
|
-
context.results = [...(context.results ?? []), ...result.suites];
|
|
70
|
-
if (config.resetEnvironmentBetweenTestFiles) {
|
|
71
|
-
shouldRestart = true;
|
|
72
|
-
}
|
|
73
|
-
runSpinner.stop(`Test file ${testFile} completed`);
|
|
74
|
-
}
|
|
75
|
-
runSpinner.stop('Tests completed');
|
|
76
|
-
};
|
|
77
|
-
const cleanUp = async (context) => {
|
|
78
|
-
if (context.bridge) {
|
|
79
|
-
context.bridge.dispose();
|
|
80
|
-
}
|
|
81
|
-
if (context.environment) {
|
|
82
|
-
await context.environment.dispose();
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const hasFailedTests = (results) => {
|
|
86
|
-
for (const suite of results) {
|
|
87
|
-
// Check if the suite itself failed
|
|
88
|
-
if (suite.status === 'failed') {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
// Check individual tests in the suite
|
|
92
|
-
for (const test of suite.tests) {
|
|
93
|
-
if (test.status === 'failed') {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// Recursively check nested suites
|
|
98
|
-
if (suite.suites && hasFailedTests(suite.suites)) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
};
|
|
104
|
-
export const testCommand = async (runnerName, options = {}) => {
|
|
105
|
-
intro('React Native Test Harness');
|
|
106
|
-
const { config, projectRoot } = await getConfig(process.cwd());
|
|
107
|
-
const selectedRunnerName = runnerName ?? config.defaultRunner;
|
|
108
|
-
if (!selectedRunnerName) {
|
|
109
|
-
throw new NoRunnerSpecifiedError(config.runners);
|
|
110
|
-
}
|
|
111
|
-
const runner = config.runners.find((r) => r.name === selectedRunnerName);
|
|
112
|
-
if (!runner) {
|
|
113
|
-
throw new RunnerNotFoundError(selectedRunnerName, config.runners);
|
|
114
|
-
}
|
|
115
|
-
const context = {
|
|
116
|
-
config,
|
|
117
|
-
runner,
|
|
118
|
-
testFiles: [],
|
|
119
|
-
results: [],
|
|
120
|
-
projectRoot,
|
|
121
|
-
};
|
|
122
|
-
try {
|
|
123
|
-
await setupEnvironment(context);
|
|
124
|
-
await findTestFiles(context, options);
|
|
125
|
-
await runTests(context, options);
|
|
126
|
-
assert(context.results != null, 'Results not initialized');
|
|
127
|
-
config.reporter?.report(context.results);
|
|
128
|
-
}
|
|
129
|
-
finally {
|
|
130
|
-
await cleanUp(context);
|
|
131
|
-
}
|
|
132
|
-
// Check if any tests failed and exit with appropriate code
|
|
133
|
-
if (hasFailedTests(context.results)) {
|
|
134
|
-
outro('Test run completed with failures');
|
|
135
|
-
process.exit(1);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
outro('Test run completed successfully');
|
|
139
|
-
}
|
|
140
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/discovery/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { discoverTestFiles } from './testDiscovery.js';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type TestFilterOptions = {
|
|
2
|
-
testNamePattern?: string;
|
|
3
|
-
testPathPattern?: string;
|
|
4
|
-
testPathIgnorePatterns?: string[];
|
|
5
|
-
testMatch?: string[];
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Discovers test files based on patterns and filtering options
|
|
9
|
-
*/
|
|
10
|
-
export declare const discoverTestFiles: (projectRoot: string, configInclude: string | string[], options?: TestFilterOptions) => Promise<string[]>;
|
|
11
|
-
//# sourceMappingURL=testDiscovery.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testDiscovery.d.ts","sourceRoot":"","sources":["../../src/discovery/testDiscovery.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,aAAa,MAAM,EACnB,eAAe,MAAM,GAAG,MAAM,EAAE,EAChC,UAAS,iBAAsB,KAC9B,OAAO,CAAC,MAAM,EAAE,CAiClB,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Glob } from 'glob';
|
|
2
|
-
/**
|
|
3
|
-
* Discovers test files based on patterns and filtering options
|
|
4
|
-
*/
|
|
5
|
-
export const discoverTestFiles = async (projectRoot, configInclude, options = {}) => {
|
|
6
|
-
// Priority: testMatch > configInclude
|
|
7
|
-
const patterns = options.testMatch || configInclude;
|
|
8
|
-
const patternArray = Array.isArray(patterns) ? patterns : [patterns];
|
|
9
|
-
// Glob discovery
|
|
10
|
-
const allFiles = [];
|
|
11
|
-
for (const pattern of patternArray) {
|
|
12
|
-
const glob = new Glob(pattern, { cwd: projectRoot, nodir: true });
|
|
13
|
-
const files = await glob.walk();
|
|
14
|
-
allFiles.push(...files);
|
|
15
|
-
}
|
|
16
|
-
// Remove duplicates
|
|
17
|
-
let uniqueFiles = [...new Set(allFiles)];
|
|
18
|
-
// Apply testPathPattern filtering
|
|
19
|
-
if (options.testPathPattern) {
|
|
20
|
-
const regex = new RegExp(options.testPathPattern);
|
|
21
|
-
uniqueFiles = uniqueFiles.filter((file) => regex.test(file));
|
|
22
|
-
}
|
|
23
|
-
// Apply testPathIgnorePatterns filtering
|
|
24
|
-
if (options.testPathIgnorePatterns?.length) {
|
|
25
|
-
const ignoreRegexes = options.testPathIgnorePatterns.map((p) => new RegExp(p));
|
|
26
|
-
uniqueFiles = uniqueFiles.filter((file) => !ignoreRegexes.some((regex) => regex.test(file)));
|
|
27
|
-
}
|
|
28
|
-
return uniqueFiles;
|
|
29
|
-
};
|
|
@@ -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":"AAiBA,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,MAqK5C,CAAC"}
|
|
@@ -1,152 +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, BridgeTimeoutError, BundlingFailedError, MetroPortUnavailableError, } from './errors.js';
|
|
4
|
-
export const formatError = (error) => {
|
|
5
|
-
const lines = [];
|
|
6
|
-
if (error instanceof AssertionError) {
|
|
7
|
-
lines.push(`\n❌ Assertion Error`);
|
|
8
|
-
lines.push(`\nError: ${error.message}`);
|
|
9
|
-
lines.push(`\nPlease check your configuration and try again.`);
|
|
10
|
-
}
|
|
11
|
-
else if (error instanceof ConfigValidationError) {
|
|
12
|
-
lines.push(`\n❌ Configuration Error`);
|
|
13
|
-
lines.push(`\nFile: ${error.filePath}`);
|
|
14
|
-
lines.push(`\nValidation errors:`);
|
|
15
|
-
error.validationErrors.forEach((err) => {
|
|
16
|
-
lines.push(` • ${err}`);
|
|
17
|
-
});
|
|
18
|
-
lines.push(`\nPlease fix the configuration errors and try again.`);
|
|
19
|
-
}
|
|
20
|
-
else if (error instanceof ConfigNotFoundError) {
|
|
21
|
-
lines.push(`\n❌ Configuration Not Found`);
|
|
22
|
-
lines.push(`\nCould not find 'rn-harness.config' in '${error.searchPath}' or any parent directories.`);
|
|
23
|
-
lines.push(`\nSupported file extensions: .js, .mjs, .cjs, .json`);
|
|
24
|
-
lines.push(`\nPlease create a configuration file or run from a directory that contains one.`);
|
|
25
|
-
}
|
|
26
|
-
else if (error instanceof ConfigLoadError) {
|
|
27
|
-
lines.push(`\n❌ Configuration Load Error`);
|
|
28
|
-
lines.push(`\nFile: ${error.filePath}`);
|
|
29
|
-
lines.push(`Error: ${error.message}`);
|
|
30
|
-
if (error.cause) {
|
|
31
|
-
lines.push(`\nCause: ${error.cause.message}`);
|
|
32
|
-
}
|
|
33
|
-
lines.push(`\nPlease check your configuration file syntax and try again.`);
|
|
34
|
-
}
|
|
35
|
-
else if (error instanceof NoRunnerSpecifiedError) {
|
|
36
|
-
lines.push('\n❌ No runner specified');
|
|
37
|
-
lines.push('\nPlease specify a runner name or set a defaultRunner in your config.');
|
|
38
|
-
lines.push('\nUsage: react-native-harness test [runner-name] [pattern]');
|
|
39
|
-
lines.push('\nAvailable runners:');
|
|
40
|
-
error.availableRunners.forEach((r) => {
|
|
41
|
-
lines.push(` • ${r.name} (${r.platform})`);
|
|
42
|
-
});
|
|
43
|
-
lines.push('\nTo set a default runner, add "defaultRunner" to your config:');
|
|
44
|
-
lines.push(' { "defaultRunner": "your-runner-name" }');
|
|
45
|
-
}
|
|
46
|
-
else if (error instanceof RunnerNotFoundError) {
|
|
47
|
-
lines.push(`\n❌ Runner "${error.runnerName}" not found`);
|
|
48
|
-
lines.push('\nAvailable runners:');
|
|
49
|
-
error.availableRunners.forEach((r) => {
|
|
50
|
-
lines.push(` • ${r.name} (${r.platform})`);
|
|
51
|
-
});
|
|
52
|
-
lines.push('\nTo add a new runner, update your rn-harness.config file.');
|
|
53
|
-
}
|
|
54
|
-
else if (error instanceof EnvironmentInitializationError) {
|
|
55
|
-
lines.push(`\n❌ Environment Initialization Error`);
|
|
56
|
-
lines.push(`\nRunner: ${error.runnerName} (${error.platform})`);
|
|
57
|
-
lines.push(`\nError: ${error.message}`);
|
|
58
|
-
if (error.details) {
|
|
59
|
-
lines.push(`\nDetails: ${error.details}`);
|
|
60
|
-
}
|
|
61
|
-
lines.push(`\nTroubleshooting steps:`);
|
|
62
|
-
lines.push(` • Verify that ${error.platform} development environment is properly set up`);
|
|
63
|
-
lines.push(` • Check that the app is built and ready for testing`);
|
|
64
|
-
lines.push(` • Ensure all required dependencies are installed`);
|
|
65
|
-
if (error.platform === 'ios') {
|
|
66
|
-
lines.push(` • Verify Xcode and iOS Simulator are working correctly`);
|
|
67
|
-
}
|
|
68
|
-
else if (error.platform === 'android') {
|
|
69
|
-
lines.push(` • Verify Android SDK and emulator are working correctly`);
|
|
70
|
-
}
|
|
71
|
-
lines.push(`\nPlease check your environment configuration and try again.`);
|
|
72
|
-
}
|
|
73
|
-
else if (error instanceof TestExecutionError) {
|
|
74
|
-
lines.push(`\n❌ Test Execution Error`);
|
|
75
|
-
lines.push(`\nFile: ${error.testFile}`);
|
|
76
|
-
if (error.testSuite) {
|
|
77
|
-
lines.push(`\nSuite: ${error.testSuite}`);
|
|
78
|
-
}
|
|
79
|
-
if (error.testName) {
|
|
80
|
-
lines.push(`\nTest: ${error.testName}`);
|
|
81
|
-
}
|
|
82
|
-
lines.push(`\nError: ${error.message}`);
|
|
83
|
-
lines.push(`\nTroubleshooting steps:`);
|
|
84
|
-
lines.push(` • Check the test file syntax and logic`);
|
|
85
|
-
lines.push(` • Verify all test dependencies are available`);
|
|
86
|
-
lines.push(` • Ensure the app is in the expected state for the test`);
|
|
87
|
-
lines.push(` • Check device/emulator logs for additional error details`);
|
|
88
|
-
lines.push(`\nPlease check your test file and try again.`);
|
|
89
|
-
}
|
|
90
|
-
else if (error instanceof RpcClientError) {
|
|
91
|
-
lines.push(`\n❌ RPC Client Error`);
|
|
92
|
-
lines.push(`\nError: ${error.message}`);
|
|
93
|
-
if (error.bridgePort) {
|
|
94
|
-
lines.push(`\nBridge Port: ${error.bridgePort}`);
|
|
95
|
-
}
|
|
96
|
-
if (error.connectionStatus) {
|
|
97
|
-
lines.push(`\nConnection Status: ${error.connectionStatus}`);
|
|
98
|
-
}
|
|
99
|
-
lines.push(`\nTroubleshooting steps:`);
|
|
100
|
-
lines.push(` • Verify the React Native app is running and connected`);
|
|
101
|
-
lines.push(` • Check that the bridge port is not blocked by firewall`);
|
|
102
|
-
lines.push(` • Ensure the app has the React Native Harness runtime integrated`);
|
|
103
|
-
lines.push(` • Try restarting the app and test harness`);
|
|
104
|
-
lines.push(`\nPlease check your bridge connection and try again.`);
|
|
105
|
-
}
|
|
106
|
-
else if (error instanceof BundlingFailedError) {
|
|
107
|
-
lines.push(`\n❌ Test File Bundling Error`);
|
|
108
|
-
lines.push(`\nFile: ${error.modulePath}`);
|
|
109
|
-
lines.push(`\nError: ${error.reason}`);
|
|
110
|
-
lines.push(`\nTroubleshooting steps:`);
|
|
111
|
-
lines.push(` • Check the test file syntax and imports`);
|
|
112
|
-
lines.push(` • Verify all imported modules exist and are accessible`);
|
|
113
|
-
lines.push(` • Ensure the Metro bundler configuration is correct`);
|
|
114
|
-
lines.push(` • Check for any circular dependencies in the test file`);
|
|
115
|
-
lines.push(` • Verify that all required packages are installed`);
|
|
116
|
-
lines.push(`\nPlease fix the bundling issues and try again.`);
|
|
117
|
-
}
|
|
118
|
-
else if (error instanceof BridgeTimeoutError) {
|
|
119
|
-
lines.push(`\n❌ Bridge Connection Timeout`);
|
|
120
|
-
lines.push(`\nThe bridge connection timed out after ${error.timeout}ms while waiting for the "${error.runnerName}" (${error.platform}) runner to be ready.`);
|
|
121
|
-
lines.push(`\nThis usually indicates that:`);
|
|
122
|
-
lines.push(` • The React Native app failed to load or connect to the bridge`);
|
|
123
|
-
lines.push(` • The app crashed during startup`);
|
|
124
|
-
lines.push(` • Network connectivity issues between the app and the test harness`);
|
|
125
|
-
lines.push(` • The app is taking longer than expected to initialize`);
|
|
126
|
-
lines.push(`\nTo resolve this issue:`);
|
|
127
|
-
lines.push(` • Check that the app is properly installed and can start normally`);
|
|
128
|
-
lines.push(` • Verify that the app has the React Native Harness runtime integrated`);
|
|
129
|
-
lines.push(` • Check device/emulator logs for any startup errors`);
|
|
130
|
-
lines.push(` • Ensure the test harness bridge port (3001) is not blocked`);
|
|
131
|
-
lines.push(`\nIf the app needs more time to start, consider increasing the timeout in the configuration.`);
|
|
132
|
-
}
|
|
133
|
-
else if (error instanceof MetroPortUnavailableError) {
|
|
134
|
-
lines.push(`\n❌ Metro Port Unavailable`);
|
|
135
|
-
lines.push(`\nPort ${error.port} is already in use or unavailable.`);
|
|
136
|
-
lines.push(`\nThis usually indicates that:`);
|
|
137
|
-
lines.push(` • Another Metro bundler instance is already running`);
|
|
138
|
-
lines.push(` • Another application is using port ${error.port}`);
|
|
139
|
-
lines.push(` • The port is blocked by a firewall or security software`);
|
|
140
|
-
lines.push(`\nTo resolve this issue:`);
|
|
141
|
-
lines.push(` • Stop any running Metro bundler instances`);
|
|
142
|
-
lines.push(` • Check for other applications using port ${error.port}: lsof -i :${error.port}`);
|
|
143
|
-
lines.push(` • Kill the process using the port: kill -9 <PID>`);
|
|
144
|
-
lines.push(` • Or use a different port by updating your Metro configuration`);
|
|
145
|
-
lines.push(`\nPlease free up the port and try again.`);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
// Re-throw the error to be handled by the caller
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
return lines.join('');
|
|
152
|
-
};
|
package/dist/errors/errors.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
type TestRunnerConfig = any;
|
|
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 BundlingFailedError extends Error {
|
|
36
|
-
readonly modulePath: string;
|
|
37
|
-
readonly reason: string;
|
|
38
|
-
constructor(modulePath: string, reason: string);
|
|
39
|
-
}
|
|
40
|
-
export declare class MetroPortUnavailableError extends Error {
|
|
41
|
-
readonly port: number;
|
|
42
|
-
constructor(port: number);
|
|
43
|
-
}
|
|
44
|
-
export {};
|
|
45
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG,GAAG,CAAC;AAE5B,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,mBAAoB,SAAQ,KAAK;aAE1B,UAAU,EAAE,MAAM;aAClB,MAAM,EAAE,MAAM;gBADd,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM;CAKjC;AAED,qBAAa,yBAA0B,SAAQ,KAAK;aACtB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAIzC"}
|
package/dist/errors/errors.js
DELETED
|
@@ -1,89 +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 BundlingFailedError extends Error {
|
|
73
|
-
modulePath;
|
|
74
|
-
reason;
|
|
75
|
-
constructor(modulePath, reason) {
|
|
76
|
-
super(`Bundling of ${modulePath} failed: ${reason}`);
|
|
77
|
-
this.modulePath = modulePath;
|
|
78
|
-
this.reason = reason;
|
|
79
|
-
this.name = 'BundlingFailedError';
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export class MetroPortUnavailableError extends Error {
|
|
83
|
-
port;
|
|
84
|
-
constructor(port) {
|
|
85
|
-
super(`Metro port ${port} is not available`);
|
|
86
|
-
this.port = port;
|
|
87
|
-
this.name = 'MetroPortUnavailableError';
|
|
88
|
-
}
|
|
89
|
-
}
|
package/dist/jest.d.ts
DELETED
package/dist/jest.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../src/jest.ts"],"names":[],"mappings":""}
|
package/dist/jest.js
DELETED
|
@@ -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
|
-
type Device = any;
|
|
2
|
-
export declare const listDevices: () => Promise<{
|
|
3
|
-
devices: Device[];
|
|
4
|
-
}>;
|
|
5
|
-
export declare const getDeviceByName: (simulatorName: string) => Promise<Device | null>;
|
|
6
|
-
export declare const listApps: (udid: string) => Promise<string[]>;
|
|
7
|
-
export declare const isAppInstalled: (simulatorName: string, bundleId: string) => Promise<boolean>;
|
|
8
|
-
export declare const runApp: (simulatorName: string, appName: string) => Promise<void>;
|
|
9
|
-
export declare const killApp: (simulatorName: string, appName: string) => Promise<void>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=device.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../src/platforms/ios/device.ts"],"names":[],"mappings":"AAGA,KAAK,MAAM,GAAG,GAAG,CAAC;AAElB,eAAO,MAAM,WAAW,QAAa,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAQjE,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,eAAe,MAAM,KACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAavB,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,MAAM,EAAE,CAY7D,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,eAAe,MAAM,EACrB,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,CASjB,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,eAAe,MAAM,EACrB,SAAS,MAAM,KACd,OAAO,CAAC,IAAI,CAGd,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,eAAe,MAAM,EACrB,SAAS,MAAM,KACd,OAAO,CAAC,IAAI,CAOd,CAAC"}
|