@react-native-harness/cli 1.0.0-alpha.15 → 1.0.0-alpha.17
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/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +4 -2
- package/dist/errors/errorHandler.d.ts +1 -1
- package/dist/errors/errorHandler.d.ts.map +1 -1
- package/dist/errors/errorHandler.js +111 -109
- package/dist/external.d.ts +11 -0
- package/dist/external.d.ts.map +1 -0
- package/dist/external.js +27 -0
- package/dist/index.js +58 -49
- package/dist/jest.d.ts +2 -0
- package/dist/jest.d.ts.map +1 -0
- package/dist/jest.js +7 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +26 -8
- package/src/errors/errorHandler.ts +113 -121
- package/src/external.ts +47 -0
- package/src/index.ts +65 -72
- package/src/commands/test.ts +0 -228
- package/src/discovery/index.ts +0 -2
- package/src/discovery/testDiscovery.ts +0 -50
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAiK/B,eAAO,MAAM,WAAW,GACtB,aAAa,MAAM,EACnB,UAAS,iBAAsB,KAC9B,OAAO,CAAC,IAAI,CA0Cd,CAAC"}
|
package/dist/commands/test.js
CHANGED
|
@@ -40,7 +40,7 @@ const findTestFiles = async (context, options = {}) => {
|
|
|
40
40
|
discoverSpinner.stop(`Found ${context.testFiles.length} test files`);
|
|
41
41
|
};
|
|
42
42
|
const runTests = async (context, options = {}) => {
|
|
43
|
-
const { bridge, environment, testFiles } = context;
|
|
43
|
+
const { bridge, environment, testFiles, config } = context;
|
|
44
44
|
assert(bridge != null, 'Bridge not initialized');
|
|
45
45
|
assert(environment != null, 'Environment not initialized');
|
|
46
46
|
assert(testFiles != null, 'Test files not initialized');
|
|
@@ -67,7 +67,9 @@ const runTests = async (context, options = {}) => {
|
|
|
67
67
|
};
|
|
68
68
|
const result = await client.runTests(testFile, executionOptions);
|
|
69
69
|
context.results = [...(context.results ?? []), ...result.suites];
|
|
70
|
-
|
|
70
|
+
if (config.resetEnvironmentBetweenTestFiles) {
|
|
71
|
+
shouldRestart = true;
|
|
72
|
+
}
|
|
71
73
|
runSpinner.stop(`Test file ${testFile} completed`);
|
|
72
74
|
}
|
|
73
75
|
runSpinner.stop('Tests completed');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
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,
|
|
1
|
+
{"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/errors/errorHandler.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,MAuM5C,CAAC"}
|
|
@@ -1,174 +1,176 @@
|
|
|
1
1
|
import { ConfigLoadError, ConfigNotFoundError, ConfigValidationError, } from '@react-native-harness/config';
|
|
2
2
|
import { AssertionError } from '../utils.js';
|
|
3
3
|
import { NoRunnerSpecifiedError, RunnerNotFoundError, EnvironmentInitializationError, TestExecutionError, RpcClientError, AppNotInstalledError, BridgeTimeoutError, BundlingFailedError, MetroPortUnavailableError, } from './errors.js';
|
|
4
|
-
export const
|
|
4
|
+
export const formatError = (error) => {
|
|
5
|
+
const lines = [];
|
|
5
6
|
if (error instanceof AssertionError) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
lines.push(`\n❌ Configuration Error`);
|
|
13
|
+
lines.push(`\nFile: ${error.filePath}`);
|
|
14
|
+
lines.push(`\nValidation errors:`);
|
|
14
15
|
error.validationErrors.forEach((err) => {
|
|
15
|
-
|
|
16
|
+
lines.push(` • ${err}`);
|
|
16
17
|
});
|
|
17
|
-
|
|
18
|
+
lines.push(`\nPlease fix the configuration errors and try again.`);
|
|
18
19
|
}
|
|
19
20
|
else if (error instanceof ConfigNotFoundError) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
31
|
+
lines.push(`\nCause: ${error.cause.message}`);
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
lines.push(`\nPlease check your configuration file syntax and try again.`);
|
|
33
34
|
}
|
|
34
35
|
else if (error instanceof NoRunnerSpecifiedError) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
41
|
+
lines.push(` • ${r.name} (${r.platform})`);
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
47
|
-
|
|
47
|
+
lines.push(`\n❌ Runner "${error.runnerName}" not found`);
|
|
48
|
+
lines.push('\nAvailable runners:');
|
|
48
49
|
error.availableRunners.forEach((r) => {
|
|
49
|
-
|
|
50
|
+
lines.push(` • ${r.name} (${r.platform})`);
|
|
50
51
|
});
|
|
51
|
-
|
|
52
|
+
lines.push('\nTo add a new runner, update your rn-harness.config file.');
|
|
52
53
|
}
|
|
53
54
|
else if (error instanceof EnvironmentInitializationError) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
59
|
+
lines.push(`\nDetails: ${error.details}`);
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
66
|
+
lines.push(` • Verify Xcode and iOS Simulator are working correctly`);
|
|
66
67
|
}
|
|
67
68
|
else if (error.platform === 'android') {
|
|
68
|
-
|
|
69
|
+
lines.push(` • Verify Android SDK and emulator are working correctly`);
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
lines.push(`\nPlease check your environment configuration and try again.`);
|
|
71
72
|
}
|
|
72
73
|
else if (error instanceof TestExecutionError) {
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
lines.push(`\n❌ Test Execution Error`);
|
|
75
|
+
lines.push(`\nFile: ${error.testFile}`);
|
|
75
76
|
if (error.testSuite) {
|
|
76
|
-
|
|
77
|
+
lines.push(`\nSuite: ${error.testSuite}`);
|
|
77
78
|
}
|
|
78
79
|
if (error.testName) {
|
|
79
|
-
|
|
80
|
+
lines.push(`\nTest: ${error.testName}`);
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
91
|
-
|
|
91
|
+
lines.push(`\n❌ RPC Client Error`);
|
|
92
|
+
lines.push(`\nError: ${error.message}`);
|
|
92
93
|
if (error.bridgePort) {
|
|
93
|
-
|
|
94
|
+
lines.push(`\nBridge Port: ${error.bridgePort}`);
|
|
94
95
|
}
|
|
95
96
|
if (error.connectionStatus) {
|
|
96
|
-
|
|
97
|
+
lines.push(`\nConnection Status: ${error.connectionStatus}`);
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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.`);
|
|
104
105
|
}
|
|
105
106
|
else if (error instanceof AppNotInstalledError) {
|
|
106
|
-
|
|
107
|
+
lines.push(`\n❌ App Not Installed`);
|
|
107
108
|
const deviceType = error.platform === 'ios'
|
|
108
109
|
? 'simulator'
|
|
109
110
|
: error.platform === 'android'
|
|
110
111
|
? 'emulator'
|
|
111
112
|
: 'virtual device';
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
lines.push(`\nThe app "${error.bundleId}" is not installed on ${deviceType} "${error.deviceName}".`);
|
|
114
|
+
lines.push(`\nTo resolve this issue:`);
|
|
114
115
|
if (error.platform === 'ios') {
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
lines.push(` • Build and install the app: npx react-native run-ios --simulator="${error.deviceName}"`);
|
|
117
|
+
lines.push(` • Or install from Xcode: Open ios/*.xcworkspace and run the project`);
|
|
117
118
|
}
|
|
118
119
|
else if (error.platform === 'android') {
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
lines.push(` • Build and install the app: npx react-native run-android`);
|
|
121
|
+
lines.push(` • Or build manually: ./gradlew assembleDebug && adb install android/app/build/outputs/apk/debug/app-debug.apk`);
|
|
121
122
|
}
|
|
122
123
|
else if (error.platform === 'vega') {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
lines.push(` • Build the Vega app: npm run build:app`);
|
|
125
|
+
lines.push(` • Install the app: kepler device install-app -p <path-to-vpkg> --device "${error.deviceName}"`);
|
|
126
|
+
lines.push(` • Or use the combined command: kepler run-kepler <path-to-vpkg> "${error.bundleId}" -d "${error.deviceName}"`);
|
|
126
127
|
}
|
|
127
|
-
|
|
128
|
+
lines.push(`\nPlease install the app and try running the tests again.`);
|
|
128
129
|
}
|
|
129
130
|
else if (error instanceof BundlingFailedError) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
lines.push(`\n❌ Test File Bundling Error`);
|
|
132
|
+
lines.push(`\nFile: ${error.modulePath}`);
|
|
133
|
+
lines.push(`\nError: ${error.reason}`);
|
|
134
|
+
lines.push(`\nTroubleshooting steps:`);
|
|
135
|
+
lines.push(` • Check the test file syntax and imports`);
|
|
136
|
+
lines.push(` • Verify all imported modules exist and are accessible`);
|
|
137
|
+
lines.push(` • Ensure the Metro bundler configuration is correct`);
|
|
138
|
+
lines.push(` • Check for any circular dependencies in the test file`);
|
|
139
|
+
lines.push(` • Verify that all required packages are installed`);
|
|
140
|
+
lines.push(`\nPlease fix the bundling issues and try again.`);
|
|
140
141
|
}
|
|
141
142
|
else if (error instanceof BridgeTimeoutError) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
lines.push(`\n❌ Bridge Connection Timeout`);
|
|
144
|
+
lines.push(`\nThe bridge connection timed out after ${error.timeout}ms while waiting for the "${error.runnerName}" (${error.platform}) runner to be ready.`);
|
|
145
|
+
lines.push(`\nThis usually indicates that:`);
|
|
146
|
+
lines.push(` • The React Native app failed to load or connect to the bridge`);
|
|
147
|
+
lines.push(` • The app crashed during startup`);
|
|
148
|
+
lines.push(` • Network connectivity issues between the app and the test harness`);
|
|
149
|
+
lines.push(` • The app is taking longer than expected to initialize`);
|
|
150
|
+
lines.push(`\nTo resolve this issue:`);
|
|
151
|
+
lines.push(` • Check that the app is properly installed and can start normally`);
|
|
152
|
+
lines.push(` • Verify that the app has the React Native Harness runtime integrated`);
|
|
153
|
+
lines.push(` • Check device/emulator logs for any startup errors`);
|
|
154
|
+
lines.push(` • Ensure the test harness bridge port (3001) is not blocked`);
|
|
155
|
+
lines.push(`\nIf the app needs more time to start, consider increasing the timeout in the configuration.`);
|
|
155
156
|
}
|
|
156
157
|
else if (error instanceof MetroPortUnavailableError) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
158
|
+
lines.push(`\n❌ Metro Port Unavailable`);
|
|
159
|
+
lines.push(`\nPort ${error.port} is already in use or unavailable.`);
|
|
160
|
+
lines.push(`\nThis usually indicates that:`);
|
|
161
|
+
lines.push(` • Another Metro bundler instance is already running`);
|
|
162
|
+
lines.push(` • Another application is using port ${error.port}`);
|
|
163
|
+
lines.push(` • The port is blocked by a firewall or security software`);
|
|
164
|
+
lines.push(`\nTo resolve this issue:`);
|
|
165
|
+
lines.push(` • Stop any running Metro bundler instances`);
|
|
166
|
+
lines.push(` • Check for other applications using port ${error.port}: lsof -i :${error.port}`);
|
|
167
|
+
lines.push(` • Kill the process using the port: kill -9 <PID>`);
|
|
168
|
+
lines.push(` • Or use a different port by updating your Metro configuration`);
|
|
169
|
+
lines.push(`\nPlease free up the port and try again.`);
|
|
169
170
|
}
|
|
170
171
|
else {
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
// Re-throw the error to be handled by the caller
|
|
173
|
+
throw error;
|
|
173
174
|
}
|
|
175
|
+
return lines.join('');
|
|
174
176
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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>;
|
|
9
|
+
export { formatError } from './errors/errorHandler.js';
|
|
10
|
+
export * from './errors/errors.js';
|
|
11
|
+
//# sourceMappingURL=external.d.ts.map
|
|
@@ -0,0 +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;AAEF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,cAAc,oBAAoB,CAAC"}
|
package/dist/external.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
};
|
|
26
|
+
export { formatError } from './errors/errorHandler.js';
|
|
27
|
+
export * from './errors/errors.js';
|
package/dist/index.js
CHANGED
|
@@ -1,52 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
44
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../src/jest.ts"],"names":[],"mappings":""}
|