@react-native-harness/cli 1.0.0-canary.1761046904277 → 1.0.0-canary.1761729829908

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.
Files changed (41) hide show
  1. package/dist/errors/errorHandler.d.ts +1 -1
  2. package/dist/errors/errorHandler.d.ts.map +1 -1
  3. package/dist/errors/errorHandler.js +101 -123
  4. package/dist/errors/errors.d.ts +2 -7
  5. package/dist/errors/errors.d.ts.map +1 -1
  6. package/dist/errors/errors.js +0 -17
  7. package/dist/external.d.ts +1 -8
  8. package/dist/external.d.ts.map +1 -1
  9. package/dist/external.js +1 -25
  10. package/dist/index.js +58 -49
  11. package/dist/jest.d.ts +2 -0
  12. package/dist/jest.d.ts.map +1 -0
  13. package/dist/jest.js +7 -0
  14. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  15. package/package.json +8 -7
  16. package/src/external.ts +0 -44
  17. package/src/index.ts +65 -72
  18. package/tsconfig.json +0 -3
  19. package/tsconfig.lib.json +1 -12
  20. package/src/bundlers/metro.ts +0 -102
  21. package/src/commands/test.ts +0 -232
  22. package/src/discovery/index.ts +0 -2
  23. package/src/discovery/testDiscovery.ts +0 -50
  24. package/src/errors/errorHandler.ts +0 -226
  25. package/src/errors/errors.ts +0 -131
  26. package/src/platforms/android/build.ts +0 -49
  27. package/src/platforms/android/device.ts +0 -48
  28. package/src/platforms/android/emulator.ts +0 -137
  29. package/src/platforms/android/index.ts +0 -87
  30. package/src/platforms/ios/build.ts +0 -71
  31. package/src/platforms/ios/device.ts +0 -79
  32. package/src/platforms/ios/index.ts +0 -66
  33. package/src/platforms/ios/simulator.ts +0 -171
  34. package/src/platforms/platform-adapter.ts +0 -11
  35. package/src/platforms/platform-registry.ts +0 -26
  36. package/src/platforms/vega/build.ts +0 -85
  37. package/src/platforms/vega/device.ts +0 -258
  38. package/src/platforms/vega/index.ts +0 -107
  39. package/src/platforms/web/index.ts +0 -16
  40. package/src/process.ts +0 -33
  41. package/src/utils.ts +0 -29
@@ -1,2 +1,2 @@
1
- export declare const handleError: (error: unknown) => void;
1
+ export declare const formatError: (error: unknown) => string;
2
2
  //# sourceMappingURL=errorHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/errors/errorHandler.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,IA+M5C,CAAC"}
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,174 +1,152 @@
1
1
  import { ConfigLoadError, ConfigNotFoundError, ConfigValidationError, } from '@react-native-harness/config';
2
2
  import { AssertionError } from '../utils.js';
3
- import { NoRunnerSpecifiedError, RunnerNotFoundError, EnvironmentInitializationError, TestExecutionError, RpcClientError, AppNotInstalledError, BridgeTimeoutError, BundlingFailedError, MetroPortUnavailableError, } from './errors.js';
4
- export const handleError = (error) => {
3
+ import { NoRunnerSpecifiedError, RunnerNotFoundError, EnvironmentInitializationError, TestExecutionError, RpcClientError, BridgeTimeoutError, BundlingFailedError, MetroPortUnavailableError, } from './errors.js';
4
+ export const formatError = (error) => {
5
+ const lines = [];
5
6
  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.`);
7
+ lines.push(`\n❌ Assertion Error`);
8
+ lines.push(`\nError: ${error.message}`);
9
+ lines.push(`\nPlease check your configuration and try again.`);
9
10
  }
10
11
  else if (error instanceof ConfigValidationError) {
11
- console.error(`\n❌ Configuration Error`);
12
- console.error(`\nFile: ${error.filePath}`);
13
- console.error(`\nValidation errors:`);
12
+ lines.push(`\n❌ Configuration Error`);
13
+ lines.push(`\nFile: ${error.filePath}`);
14
+ lines.push(`\nValidation errors:`);
14
15
  error.validationErrors.forEach((err) => {
15
- console.error(` • ${err}`);
16
+ lines.push(` • ${err}`);
16
17
  });
17
- console.error(`\nPlease fix the configuration errors and try again.`);
18
+ lines.push(`\nPlease fix the configuration errors and try again.`);
18
19
  }
19
20
  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.`);
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.`);
24
25
  }
25
26
  else if (error instanceof ConfigLoadError) {
26
- console.error(`\n❌ Configuration Load Error`);
27
- console.error(`\nFile: ${error.filePath}`);
28
- console.error(`Error: ${error.message}`);
27
+ lines.push(`\n❌ Configuration Load Error`);
28
+ lines.push(`\nFile: ${error.filePath}`);
29
+ lines.push(`Error: ${error.message}`);
29
30
  if (error.cause) {
30
- console.error(`\nCause: ${error.cause.message}`);
31
+ lines.push(`\nCause: ${error.cause.message}`);
31
32
  }
32
- console.error(`\nPlease check your configuration file syntax and try again.`);
33
+ lines.push(`\nPlease check your configuration file syntax and try again.`);
33
34
  }
34
35
  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:');
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:');
39
40
  error.availableRunners.forEach((r) => {
40
- console.error(` • ${r.name} (${r.platform})`);
41
+ lines.push(` • ${r.name} (${r.platform})`);
41
42
  });
42
- console.error('\nTo set a default runner, add "defaultRunner" to your config:');
43
- console.error(' { "defaultRunner": "your-runner-name" }');
43
+ lines.push('\nTo set a default runner, add "defaultRunner" to your config:');
44
+ lines.push(' { "defaultRunner": "your-runner-name" }');
44
45
  }
45
46
  else if (error instanceof RunnerNotFoundError) {
46
- console.error(`\n❌ Runner "${error.runnerName}" not found`);
47
- console.error('\nAvailable runners:');
47
+ lines.push(`\n❌ Runner "${error.runnerName}" not found`);
48
+ lines.push('\nAvailable runners:');
48
49
  error.availableRunners.forEach((r) => {
49
- console.error(` • ${r.name} (${r.platform})`);
50
+ lines.push(` • ${r.name} (${r.platform})`);
50
51
  });
51
- console.error('\nTo add a new runner, update your rn-harness.config file.');
52
+ lines.push('\nTo add a new runner, update your rn-harness.config file.');
52
53
  }
53
54
  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}`);
55
+ lines.push(`\n❌ Environment Initialization Error`);
56
+ lines.push(`\nRunner: ${error.runnerName} (${error.platform})`);
57
+ lines.push(`\nError: ${error.message}`);
57
58
  if (error.details) {
58
- console.error(`\nDetails: ${error.details}`);
59
+ lines.push(`\nDetails: ${error.details}`);
59
60
  }
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`);
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`);
64
65
  if (error.platform === 'ios') {
65
- console.error(` • Verify Xcode and iOS Simulator are working correctly`);
66
+ lines.push(` • Verify Xcode and iOS Simulator are working correctly`);
66
67
  }
67
68
  else if (error.platform === 'android') {
68
- console.error(` • Verify Android SDK and emulator are working correctly`);
69
+ lines.push(` • Verify Android SDK and emulator are working correctly`);
69
70
  }
70
- console.error(`\nPlease check your environment configuration and try again.`);
71
+ lines.push(`\nPlease check your environment configuration and try again.`);
71
72
  }
72
73
  else if (error instanceof TestExecutionError) {
73
- console.error(`\n❌ Test Execution Error`);
74
- console.error(`\nFile: ${error.testFile}`);
74
+ lines.push(`\n❌ Test Execution Error`);
75
+ lines.push(`\nFile: ${error.testFile}`);
75
76
  if (error.testSuite) {
76
- console.error(`\nSuite: ${error.testSuite}`);
77
+ lines.push(`\nSuite: ${error.testSuite}`);
77
78
  }
78
79
  if (error.testName) {
79
- console.error(`\nTest: ${error.testName}`);
80
+ lines.push(`\nTest: ${error.testName}`);
80
81
  }
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.`);
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.`);
88
89
  }
89
90
  else if (error instanceof RpcClientError) {
90
- console.error(`\n❌ RPC Client Error`);
91
- console.error(`\nError: ${error.message}`);
91
+ lines.push(`\n❌ RPC Client Error`);
92
+ lines.push(`\nError: ${error.message}`);
92
93
  if (error.bridgePort) {
93
- console.error(`\nBridge Port: ${error.bridgePort}`);
94
+ lines.push(`\nBridge Port: ${error.bridgePort}`);
94
95
  }
95
96
  if (error.connectionStatus) {
96
- console.error(`\nConnection Status: ${error.connectionStatus}`);
97
+ lines.push(`\nConnection Status: ${error.connectionStatus}`);
97
98
  }
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
- const deviceType = error.platform === 'ios'
108
- ? 'simulator'
109
- : error.platform === 'android'
110
- ? 'emulator'
111
- : 'virtual device';
112
- console.error(`\nThe app "${error.bundleId}" is not installed on ${deviceType} "${error.deviceName}".`);
113
- console.error(`\nTo resolve this issue:`);
114
- if (error.platform === 'ios') {
115
- console.error(` • Build and install the app: npx react-native run-ios --simulator="${error.deviceName}"`);
116
- console.error(` • Or install from Xcode: Open ios/*.xcworkspace and run the project`);
117
- }
118
- else if (error.platform === 'android') {
119
- console.error(` • Build and install the app: npx react-native run-android`);
120
- console.error(` • Or build manually: ./gradlew assembleDebug && adb install android/app/build/outputs/apk/debug/app-debug.apk`);
121
- }
122
- else if (error.platform === 'vega') {
123
- console.error(` • Build the Vega app: npm run build:app`);
124
- console.error(` • Install the app: kepler device install-app -p <path-to-vpkg> --device "${error.deviceName}"`);
125
- console.error(` • Or use the combined command: kepler run-kepler <path-to-vpkg> "${error.bundleId}" -d "${error.deviceName}"`);
126
- }
127
- console.error(`\nPlease install the app and try running the tests again.`);
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.`);
128
105
  }
129
106
  else if (error instanceof BundlingFailedError) {
130
- console.error(`\n❌ Test File Bundling Error`);
131
- console.error(`\nFile: ${error.modulePath}`);
132
- console.error(`\nError: ${error.reason}`);
133
- console.error(`\nTroubleshooting steps:`);
134
- console.error(` • Check the test file syntax and imports`);
135
- console.error(` • Verify all imported modules exist and are accessible`);
136
- console.error(` • Ensure the Metro bundler configuration is correct`);
137
- console.error(` • Check for any circular dependencies in the test file`);
138
- console.error(` • Verify that all required packages are installed`);
139
- console.error(`\nPlease fix the bundling issues and try again.`);
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.`);
140
117
  }
141
118
  else if (error instanceof BridgeTimeoutError) {
142
- console.error(`\n❌ Bridge Connection Timeout`);
143
- console.error(`\nThe bridge connection timed out after ${error.timeout}ms while waiting for the "${error.runnerName}" (${error.platform}) runner to be ready.`);
144
- console.error(`\nThis usually indicates that:`);
145
- console.error(` • The React Native app failed to load or connect to the bridge`);
146
- console.error(` • The app crashed during startup`);
147
- console.error(` • Network connectivity issues between the app and the test harness`);
148
- console.error(` • The app is taking longer than expected to initialize`);
149
- console.error(`\nTo resolve this issue:`);
150
- console.error(` • Check that the app is properly installed and can start normally`);
151
- console.error(` • Verify that the app has the React Native Harness runtime integrated`);
152
- console.error(` • Check device/emulator logs for any startup errors`);
153
- console.error(` • Ensure the test harness bridge port (3001) is not blocked`);
154
- console.error(`\nIf the app needs more time to start, consider increasing the timeout in the configuration.`);
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.`);
155
132
  }
156
133
  else if (error instanceof MetroPortUnavailableError) {
157
- console.error(`\n❌ Metro Port Unavailable`);
158
- console.error(`\nPort ${error.port} is already in use or unavailable.`);
159
- console.error(`\nThis usually indicates that:`);
160
- console.error(` • Another Metro bundler instance is already running`);
161
- console.error(` • Another application is using port ${error.port}`);
162
- console.error(` • The port is blocked by a firewall or security software`);
163
- console.error(`\nTo resolve this issue:`);
164
- console.error(` • Stop any running Metro bundler instances`);
165
- console.error(` • Check for other applications using port ${error.port}: lsof -i :${error.port}`);
166
- console.error(` • Kill the process using the port: kill -9 <PID>`);
167
- console.error(` • Or use a different port by updating your Metro configuration`);
168
- console.error(`\nPlease free up the port and try again.`);
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.`);
169
146
  }
170
147
  else {
171
- console.error(`\n❌ Unexpected Error`);
172
- console.error(error);
148
+ // Re-throw the error to be handled by the caller
149
+ throw error;
173
150
  }
151
+ return lines.join('');
174
152
  };
@@ -1,4 +1,4 @@
1
- import { TestRunnerConfig } from '@react-native-harness/config';
1
+ type TestRunnerConfig = any;
2
2
  export declare class NoRunnerSpecifiedError extends Error {
3
3
  constructor(availableRunners: TestRunnerConfig[]);
4
4
  availableRunners: TestRunnerConfig[];
@@ -32,12 +32,6 @@ export declare class BridgeTimeoutError extends Error {
32
32
  readonly platform: string;
33
33
  constructor(timeout: number, runnerName: string, platform: string);
34
34
  }
35
- export declare class AppNotInstalledError extends Error {
36
- readonly deviceName: string;
37
- readonly bundleId: string;
38
- readonly platform: 'ios' | 'android' | 'vega';
39
- constructor(deviceName: string, bundleId: string, platform: 'ios' | 'android' | 'vega');
40
- }
41
35
  export declare class BundlingFailedError extends Error {
42
36
  readonly modulePath: string;
43
37
  readonly reason: string;
@@ -47,4 +41,5 @@ export declare class MetroPortUnavailableError extends Error {
47
41
  readonly port: number;
48
42
  constructor(port: number);
49
43
  }
44
+ export {};
50
45
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
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,QAA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,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"}
@@ -69,23 +69,6 @@ export class BridgeTimeoutError extends Error {
69
69
  this.name = 'BridgeTimeoutError';
70
70
  }
71
71
  }
72
- export class AppNotInstalledError extends Error {
73
- deviceName;
74
- bundleId;
75
- platform;
76
- constructor(deviceName, bundleId, platform) {
77
- const deviceType = platform === 'ios'
78
- ? 'simulator'
79
- : platform === 'android'
80
- ? 'emulator'
81
- : 'virtual device';
82
- super(`App "${bundleId}" is not installed on ${deviceType} "${deviceName}"`);
83
- this.deviceName = deviceName;
84
- this.bundleId = bundleId;
85
- this.platform = platform;
86
- this.name = 'AppNotInstalledError';
87
- }
88
- }
89
72
  export class BundlingFailedError extends Error {
90
73
  modulePath;
91
74
  reason;
@@ -1,9 +1,2 @@
1
- import { TestRunnerConfig } from '@react-native-harness/config';
2
- import { Environment } from './platforms/platform-adapter.js';
3
- import { BridgeServer } from '@react-native-harness/bridge/server';
4
- export type Harness = {
5
- environment: Environment;
6
- bridge: BridgeServer;
7
- };
8
- export declare const getHarness: (runner: TestRunnerConfig) => Promise<Harness>;
1
+ export {};
9
2
  //# sourceMappingURL=external.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EACL,YAAY,EAEb,MAAM,qCAAqC,CAAC;AAI7C,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,QAAQ,gBAAgB,KACvB,OAAO,CAAC,OAAO,CA2BjB,CAAC"}
1
+ {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":""}
package/dist/external.js CHANGED
@@ -1,25 +1 @@
1
- import { getBridgeServer, } from '@react-native-harness/bridge/server';
2
- import { BridgeTimeoutError } from './errors/errors.js';
3
- import { getPlatformAdapter } from './platforms/platform-registry.js';
4
- export const getHarness = async (runner) => {
5
- const bridgeTimeout = 60000;
6
- const platformAdapter = await getPlatformAdapter(runner.platform);
7
- const serverBridge = await getBridgeServer({
8
- port: 3001,
9
- });
10
- const readyPromise = new Promise((resolve, reject) => {
11
- const timeout = setTimeout(() => {
12
- reject(new BridgeTimeoutError(bridgeTimeout, runner.name, runner.platform));
13
- }, bridgeTimeout);
14
- serverBridge.once('ready', () => {
15
- clearTimeout(timeout);
16
- resolve();
17
- });
18
- });
19
- const environment = await platformAdapter.getEnvironment(runner);
20
- await readyPromise;
21
- return {
22
- environment,
23
- bridge: serverBridge,
24
- };
25
- };
1
+ export {};
package/dist/index.js CHANGED
@@ -1,52 +1,61 @@
1
- import { Command } from 'commander';
2
- import { readFileSync } from 'fs';
3
- import { fileURLToPath } from 'url';
4
- import { dirname, join } from 'path';
5
- import { testCommand } from './commands/test.js';
6
- import { handleError } from './errors/errorHandler.js';
7
- import { logger } from '@react-native-harness/tools';
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
- const packageJsonPath = join(__dirname, '../package.json');
11
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
12
- const program = new Command();
13
- program
14
- .name('react-native-harness')
15
- .description('React Native Test Harness - A comprehensive testing framework for React Native applications')
16
- .version(packageJson.version)
17
- .option('-v, --verbose', 'Enable verbose logging')
18
- .hook('preAction', (thisCommand) => {
19
- // Handle global verbose option
20
- const opts = thisCommand.optsWithGlobals();
21
- if (opts.verbose) {
22
- logger.setVerbose(true);
23
- }
24
- });
25
- program
26
- .command('test')
27
- .description('Run tests using the specified runner')
28
- .argument('[runner]', 'test runner name (uses defaultRunner from config if not specified)')
29
- .argument('[pattern]', 'glob pattern to match test files (uses config.include if not specified)')
30
- .option('-t, --testNamePattern <pattern>', 'Run only tests with names matching regex pattern')
31
- .option('--testPathPattern <pattern>', 'Run only test files with paths matching regex pattern')
32
- .option('--testPathIgnorePatterns <patterns...>', 'Ignore test files matching these patterns')
33
- .option('--testMatch <patterns...>', 'Override config.include with these glob patterns')
34
- .action(async (runner, pattern, options) => {
1
+ import { run, yargsOptions } from 'jest-cli';
2
+ import { getConfig } from '@react-native-harness/config';
3
+ const checkForOldConfig = async () => {
35
4
  try {
36
- // Convert CLI pattern argument to testMatch option
37
- const mergedOptions = {
38
- ...options,
39
- testMatch: pattern ? [pattern] : options.testMatch,
40
- };
41
- await testCommand(runner, mergedOptions);
5
+ const { config } = await getConfig(process.cwd());
6
+ if (config.include) {
7
+ console.error('\n❌ Migration Required\n');
8
+ console.error('React Native Harness has migrated to the Jest CLI.');
9
+ console.error('The "include" property in your rn-harness.config file is no longer supported.\n');
10
+ console.error('Please follow the migration guide to update your configuration:');
11
+ console.error('https://react-native-harness.dev/docs/guides/migration-guide\n');
12
+ process.exit(1);
13
+ }
42
14
  }
43
- catch (error) {
44
- handleError(error);
45
- process.exit(1);
15
+ catch {
16
+ // Swallow the error - if we can't load the config, let Jest CLI handle it
46
17
  }
47
- });
48
- process.on('uncaughtException', (error) => {
49
- handleError(error);
50
- process.exit(1);
51
- });
52
- program.parse();
18
+ };
19
+ const patchYargsOptions = () => {
20
+ yargsOptions.harnessRunner = {
21
+ type: 'string',
22
+ description: 'Specify which Harness runner to use',
23
+ requiresArg: true,
24
+ };
25
+ // Remove all options that are not supported by Harness
26
+ delete yargsOptions.runner;
27
+ delete yargsOptions.testRunner;
28
+ delete yargsOptions.testEnvironment;
29
+ delete yargsOptions.testEnvironmentOptions;
30
+ delete yargsOptions.transform;
31
+ delete yargsOptions.transformIgnorePatterns;
32
+ delete yargsOptions.updateSnapshot;
33
+ delete yargsOptions.workerThreads;
34
+ delete yargsOptions.snapshotSerializers;
35
+ delete yargsOptions.shard;
36
+ delete yargsOptions.runInBand;
37
+ delete yargsOptions.resolver;
38
+ delete yargsOptions.resetMocks;
39
+ delete yargsOptions.resetModules;
40
+ delete yargsOptions.restoreMocks;
41
+ delete yargsOptions.preset;
42
+ delete yargsOptions.prettierPath;
43
+ delete yargsOptions.maxWorkers;
44
+ delete yargsOptions.moduleDirectories;
45
+ delete yargsOptions.moduleFileExtensions;
46
+ delete yargsOptions.moduleNameMapper;
47
+ delete yargsOptions.modulePathIgnorePatterns;
48
+ delete yargsOptions.modulePaths;
49
+ delete yargsOptions.maxConcurrency;
50
+ delete yargsOptions.injectGlobals;
51
+ delete yargsOptions.globalSetup;
52
+ delete yargsOptions.globalTeardown;
53
+ delete yargsOptions.clearMocks;
54
+ delete yargsOptions.globals;
55
+ delete yargsOptions.haste;
56
+ delete yargsOptions.automock;
57
+ delete yargsOptions.coverageProvider;
58
+ delete yargsOptions.logHeapUsage;
59
+ };
60
+ patchYargsOptions();
61
+ checkForOldConfig().then(() => run());
package/dist/jest.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../src/jest.ts"],"names":[],"mappings":""}
package/dist/jest.js ADDED
@@ -0,0 +1,7 @@
1
+ import { run, yargsOptions } from 'jest-cli';
2
+ yargsOptions.harnessRunner = {
3
+ type: 'string',
4
+ description: 'Specify which Harness runner to use',
5
+ requiresArg: true,
6
+ };
7
+ run();