@react-native-harness/runtime 1.0.0-alpha.1 → 1.0.0-alpha.11
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/bundler/bundle.d.ts.map +1 -1
- package/dist/bundler/bundle.js +7 -1
- package/dist/bundler/errors.d.ts +5 -0
- package/dist/bundler/errors.d.ts.map +1 -1
- package/dist/bundler/errors.js +10 -0
- package/dist/bundler/factory.d.ts +3 -0
- package/dist/bundler/factory.d.ts.map +1 -0
- package/dist/bundler/factory.js +36 -0
- package/dist/bundler/index.d.ts +2 -1
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/bundler/types.d.ts +7 -0
- package/dist/bundler/types.d.ts.map +1 -0
- package/dist/bundler/types.js +1 -0
- package/dist/client/factory.d.ts.map +1 -1
- package/dist/client/factory.js +13 -4
- package/dist/initialize.js +8 -6
- package/dist/mocker/registry.d.ts +2 -2
- package/dist/mocker/registry.d.ts.map +1 -1
- package/dist/runner/errors.d.ts +4 -2
- package/dist/runner/errors.d.ts.map +1 -1
- package/dist/runner/errors.js +21 -3
- package/dist/runner/runSuite.d.ts.map +1 -1
- package/dist/runner/runSuite.js +22 -7
- package/dist/symbolicate.d.ts +3 -0
- package/dist/symbolicate.d.ts.map +1 -0
- package/dist/symbolicate.js +18 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/progressLogger.d.ts +8 -0
- package/dist/utils/progressLogger.d.ts.map +1 -0
- package/dist/utils/progressLogger.js +79 -0
- package/package.json +7 -5
- package/src/bundler/bundle.ts +9 -1
- package/src/bundler/errors.ts +10 -0
- package/src/bundler/factory.ts +43 -0
- package/src/bundler/index.ts +2 -1
- package/src/bundler/types.ts +7 -0
- package/src/client/factory.ts +21 -6
- package/src/initialize.ts +11 -8
- package/src/mocker/registry.ts +3 -3
- package/src/react-native.d.ts +37 -0
- package/src/runner/errors.ts +35 -5
- package/src/runner/runSuite.ts +27 -9
- package/src/symbolicate.ts +22 -0
- package/src/utils/progressLogger.ts +98 -0
- package/dist/bundler/dev-server.d.ts +0 -2
- package/dist/bundler/dev-server.d.ts.map +0 -1
- package/dist/bundler/dev-server.js +0 -5
- package/dist/exports.d.ts +0 -7
- package/dist/exports.d.ts.map +0 -1
- package/dist/exports.js +0 -6
- package/dist/getEntryComponent.d.ts +0 -6
- package/dist/getEntryComponent.d.ts.map +0 -1
- package/dist/getEntryComponent.js +0 -6
- package/dist/logger.d.ts +0 -6
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -14
- package/dist/mock.d.ts +0 -15
- package/dist/mock.d.ts.map +0 -1
- package/dist/mock.js +0 -37
- package/dist/module.d.ts +0 -3
- package/dist/module.d.ts.map +0 -1
- package/dist/module.js +0 -19
- package/dist/module.web.d.ts +0 -2
- package/dist/module.web.d.ts.map +0 -1
- package/dist/module.web.js +0 -12
- package/dist/rntl/client.d.ts +0 -3
- package/dist/rntl/client.d.ts.map +0 -1
- package/dist/rntl/client.js +0 -8
- package/dist/rntl/describe.d.ts +0 -2
- package/dist/rntl/describe.d.ts.map +0 -1
- package/dist/rntl/describe.js +0 -1
- package/dist/rntl/expect.d.ts +0 -128
- package/dist/rntl/expect.d.ts.map +0 -1
- package/dist/rntl/expect.js +0 -670
- package/dist/rntl/fn.d.ts +0 -2
- package/dist/rntl/fn.d.ts.map +0 -1
- package/dist/rntl/fn.js +0 -1
- package/dist/rntl/mock.d.ts +0 -2
- package/dist/rntl/mock.d.ts.map +0 -1
- package/dist/rntl/mock.js +0 -1
- package/dist/rntl/render.d.ts +0 -4
- package/dist/rntl/render.d.ts.map +0 -1
- package/dist/rntl/render.js +0 -11
- package/dist/rntl/screen.d.ts +0 -45
- package/dist/rntl/screen.d.ts.map +0 -1
- package/dist/rntl/screen.js +0 -31
- package/dist/rntl/spies.d.ts +0 -45
- package/dist/rntl/spies.d.ts.map +0 -1
- package/dist/rntl/spies.js +0 -553
- package/dist/rntl/userEvent.d.ts +0 -22
- package/dist/rntl/userEvent.d.ts.map +0 -1
- package/dist/rntl/userEvent.js +0 -19
- package/dist/runner.d.ts +0 -7
- package/dist/runner.d.ts.map +0 -1
- package/dist/runner.js +0 -201
- package/dist/runtime.d.ts +0 -2
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -44
- package/dist/state.d.ts +0 -25
- package/dist/state.d.ts.map +0 -1
- package/dist/state.js +0 -37
- package/dist/ui/UI.d.ts +0 -13
- package/dist/ui/UI.d.ts.map +0 -1
- package/dist/ui/UI.js +0 -121
package/src/client/factory.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
TestRunnerEvents,
|
|
3
3
|
TestCollectorEvents,
|
|
4
|
+
BundlerEvents,
|
|
4
5
|
} from '@react-native-harness/bridge';
|
|
5
6
|
import { getBridgeClient } from '@react-native-harness/bridge/client';
|
|
6
7
|
import { store } from '../ui/state.js';
|
|
7
8
|
import { getTestRunner, TestRunner } from '../runner/index.js';
|
|
8
9
|
import { getTestCollector, TestCollector } from '../collector/index.js';
|
|
9
10
|
import { combineEventEmitters, EventEmitter } from '../utils/emitter.js';
|
|
11
|
+
import { attachProgressLogger } from '../utils/progressLogger.js';
|
|
10
12
|
import { getWSServer } from './getWSServer.js';
|
|
11
|
-
import {
|
|
13
|
+
import { getBundler, evaluateModule, Bundler } from '../bundler/index.js';
|
|
12
14
|
|
|
13
15
|
export const getClient = async () => {
|
|
14
16
|
const client = await getBridgeClient(getWSServer(), {
|
|
@@ -26,24 +28,37 @@ export const getClient = async () => {
|
|
|
26
28
|
|
|
27
29
|
let collector: TestCollector | null = null;
|
|
28
30
|
let runner: TestRunner | null = null;
|
|
29
|
-
let events: EventEmitter<
|
|
30
|
-
|
|
31
|
+
let events: EventEmitter<
|
|
32
|
+
TestRunnerEvents | TestCollectorEvents | BundlerEvents
|
|
33
|
+
> | null = null;
|
|
34
|
+
let bundler: Bundler | null = null;
|
|
31
35
|
|
|
32
36
|
try {
|
|
33
37
|
collector = getTestCollector();
|
|
34
38
|
runner = getTestRunner();
|
|
35
|
-
|
|
39
|
+
bundler = getBundler();
|
|
40
|
+
events = combineEventEmitters(
|
|
41
|
+
collector.events,
|
|
42
|
+
runner.events,
|
|
43
|
+
bundler.events
|
|
44
|
+
);
|
|
36
45
|
|
|
37
46
|
events.addListener((event) => {
|
|
38
47
|
client.rpc.emitEvent(event.type, event);
|
|
39
48
|
});
|
|
40
49
|
|
|
41
|
-
|
|
50
|
+
// Add console logging for progress information
|
|
51
|
+
attachProgressLogger(events, path);
|
|
52
|
+
|
|
53
|
+
const moduleJs = await bundler.getModule(path);
|
|
42
54
|
const collectionResult = await collector.collect(
|
|
43
55
|
() => evaluateModule(moduleJs, path),
|
|
44
56
|
path
|
|
45
57
|
);
|
|
46
|
-
|
|
58
|
+
const result = await runner.run(collectionResult.testSuite, path);
|
|
59
|
+
return result;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
throw error;
|
|
47
62
|
} finally {
|
|
48
63
|
collector?.dispose();
|
|
49
64
|
runner?.dispose();
|
package/src/initialize.ts
CHANGED
|
@@ -11,12 +11,15 @@ const { LogBox } = require('react-native');
|
|
|
11
11
|
LogBox.ignoreAllLogs(true);
|
|
12
12
|
|
|
13
13
|
// Turn off HMR
|
|
14
|
-
const
|
|
15
|
-
HMRClient
|
|
16
|
-
// No setup = no HMR
|
|
17
|
-
};
|
|
14
|
+
const HMRClientModule = require('react-native/Libraries/Utilities/HMRClient');
|
|
15
|
+
const HMRClient = 'default' in HMRClientModule ? HMRClientModule.default : HMRClientModule;
|
|
18
16
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
// Wait for HMRClient to be initialized
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
HMRClient.disable();
|
|
20
|
+
|
|
21
|
+
// Initialize the React Native Harness
|
|
22
|
+
void getClient().then((client) =>
|
|
23
|
+
client.rpc.reportReady(getDeviceDescriptor())
|
|
24
|
+
);
|
|
25
|
+
});
|
package/src/mocker/registry.ts
CHANGED
|
@@ -5,9 +5,9 @@ const mockCache = new Map<number, unknown>();
|
|
|
5
5
|
|
|
6
6
|
const originalRequire = global.__r;
|
|
7
7
|
|
|
8
|
-
export const mock = (moduleId:
|
|
9
|
-
mockCache.delete(moduleId);
|
|
10
|
-
mockRegistry.set(moduleId, factory);
|
|
8
|
+
export const mock = (moduleId: string, factory: ModuleFactory): void => {
|
|
9
|
+
mockCache.delete(moduleId as unknown as ModuleId);
|
|
10
|
+
mockRegistry.set(moduleId as unknown as ModuleId, factory);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const clearMocks = (): void => {
|
package/src/react-native.d.ts
CHANGED
|
@@ -7,6 +7,43 @@ declare module 'react-native/Libraries/Core/Devtools/getDevServer' {
|
|
|
7
7
|
export default function getDevServer(): DevServerInfo;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
declare module 'react-native/Libraries/Core/Devtools/symbolicateStackTrace' {
|
|
11
|
+
import { StackFrame } from 'react-native/Libraries/Core/Devtools/parseErrorStack';
|
|
12
|
+
|
|
13
|
+
export type CodeFrame = Readonly<{
|
|
14
|
+
content: string;
|
|
15
|
+
location:
|
|
16
|
+
| {
|
|
17
|
+
row: number;
|
|
18
|
+
column: number;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
| null
|
|
22
|
+
| undefined;
|
|
23
|
+
fileName: string;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
export type SymbolicatedStackTrace = Readonly<{
|
|
27
|
+
stack: ReadonlyArray<StackFrame>;
|
|
28
|
+
codeFrame: CodeFrame | null | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
|
|
31
|
+
export default function symbolicateStackTrace(
|
|
32
|
+
stack: ReadonlyArray<StackFrame>,
|
|
33
|
+
extraData?: any
|
|
34
|
+
): Promise<SymbolicatedStackTrace>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare module 'react-native/Libraries/Core/Devtools/parseErrorStack' {
|
|
38
|
+
export type StackFrame = {
|
|
39
|
+
column: number | null | undefined;
|
|
40
|
+
file: string | null | undefined;
|
|
41
|
+
lineNumber: number | null | undefined;
|
|
42
|
+
methodName: string;
|
|
43
|
+
};
|
|
44
|
+
export default function parseErrorStack(errorStack?: string): StackFrame[];
|
|
45
|
+
}
|
|
46
|
+
|
|
10
47
|
declare global {
|
|
11
48
|
var __r:
|
|
12
49
|
| {
|
package/src/runner/errors.ts
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import type { SerializedError } from '@react-native-harness/bridge';
|
|
1
|
+
import type { SerializedError, CodeFrame } from '@react-native-harness/bridge';
|
|
2
|
+
import { getCodeFrame } from '../symbolicate.js';
|
|
2
3
|
|
|
3
4
|
export class TestExecutionError extends Error {
|
|
4
5
|
file: string;
|
|
5
6
|
suite: string;
|
|
6
7
|
test: string;
|
|
8
|
+
codeFrame?: CodeFrame;
|
|
7
9
|
|
|
8
|
-
constructor(
|
|
10
|
+
constructor(
|
|
11
|
+
error: unknown,
|
|
12
|
+
file: string,
|
|
13
|
+
suite: string,
|
|
14
|
+
test: string,
|
|
15
|
+
codeFrame?: CodeFrame
|
|
16
|
+
) {
|
|
9
17
|
super('Test execution error');
|
|
10
18
|
this.name = 'TestExecutionError';
|
|
11
19
|
this.file = file;
|
|
12
20
|
this.suite = suite;
|
|
13
21
|
this.test = test;
|
|
14
22
|
this.cause = error;
|
|
23
|
+
this.codeFrame = codeFrame;
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
toSerializedJSON(): SerializedError {
|
|
@@ -19,13 +28,34 @@ export class TestExecutionError extends Error {
|
|
|
19
28
|
this.cause instanceof Error ? this.cause.name : 'Unknown name';
|
|
20
29
|
const causeMessage =
|
|
21
30
|
this.cause instanceof Error ? this.cause.message : 'Unknown message';
|
|
22
|
-
const
|
|
23
|
-
this.cause instanceof Error ? this.cause.stack : undefined;
|
|
31
|
+
const causeCodeFrame = this.codeFrame;
|
|
24
32
|
|
|
25
33
|
return {
|
|
26
34
|
name: causeName,
|
|
27
35
|
message: causeMessage,
|
|
28
|
-
|
|
36
|
+
codeFrame: causeCodeFrame,
|
|
29
37
|
};
|
|
30
38
|
}
|
|
31
39
|
}
|
|
40
|
+
|
|
41
|
+
export const getTestExecutionError = async (
|
|
42
|
+
error: unknown,
|
|
43
|
+
file: string,
|
|
44
|
+
suite: string,
|
|
45
|
+
test: string
|
|
46
|
+
): Promise<TestExecutionError> => {
|
|
47
|
+
try {
|
|
48
|
+
if (error instanceof Error) {
|
|
49
|
+
const codeFrame = await getCodeFrame(error);
|
|
50
|
+
|
|
51
|
+
if (codeFrame) {
|
|
52
|
+
return new TestExecutionError(error, file, suite, test, codeFrame);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return new TestExecutionError(error, file, suite, test);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
// If the stack cannot be symbolicated, return the original error
|
|
59
|
+
return new TestExecutionError(error, file, suite, test);
|
|
60
|
+
}
|
|
61
|
+
};
|
package/src/runner/runSuite.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
TestSuiteResult,
|
|
6
6
|
} from '@react-native-harness/bridge';
|
|
7
7
|
import { runHooks } from './hooks.js';
|
|
8
|
-
import {
|
|
8
|
+
import { getTestExecutionError } from './errors.js';
|
|
9
9
|
import { TestRunnerContext } from './types.js';
|
|
10
10
|
|
|
11
11
|
const runTest = async (
|
|
@@ -94,7 +94,7 @@ const runTest = async (
|
|
|
94
94
|
|
|
95
95
|
return result;
|
|
96
96
|
} catch (error) {
|
|
97
|
-
const testError =
|
|
97
|
+
const testError = await getTestExecutionError(
|
|
98
98
|
error,
|
|
99
99
|
context.testFilePath,
|
|
100
100
|
suite.name,
|
|
@@ -173,13 +173,31 @@ export const runSuite = async (
|
|
|
173
173
|
|
|
174
174
|
if (hasFailedTests || hasFailedSuites) {
|
|
175
175
|
status = 'failed';
|
|
176
|
-
} else
|
|
177
|
-
(
|
|
178
|
-
|
|
179
|
-
testResults.length > 0
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
176
|
+
} else {
|
|
177
|
+
// Check if all tests and suites are skipped (and there are some tests/suites to check)
|
|
178
|
+
const allTestsSkipped =
|
|
179
|
+
testResults.length > 0 &&
|
|
180
|
+
testResults.every((result) => result.status === 'skipped');
|
|
181
|
+
const allSuitesSkipped =
|
|
182
|
+
suiteResults.length > 0 &&
|
|
183
|
+
suiteResults.every((result) => result.status === 'skipped');
|
|
184
|
+
const hasAnyContent = testResults.length > 0 || suiteResults.length > 0;
|
|
185
|
+
|
|
186
|
+
if (
|
|
187
|
+
hasAnyContent &&
|
|
188
|
+
((testResults.length > 0 &&
|
|
189
|
+
allTestsSkipped &&
|
|
190
|
+
suiteResults.length === 0) ||
|
|
191
|
+
(suiteResults.length > 0 &&
|
|
192
|
+
allSuitesSkipped &&
|
|
193
|
+
testResults.length === 0) ||
|
|
194
|
+
(testResults.length > 0 &&
|
|
195
|
+
suiteResults.length > 0 &&
|
|
196
|
+
allTestsSkipped &&
|
|
197
|
+
allSuitesSkipped))
|
|
198
|
+
) {
|
|
199
|
+
status = 'skipped';
|
|
200
|
+
}
|
|
183
201
|
}
|
|
184
202
|
|
|
185
203
|
// Emit suite-finished event
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CodeFrame } from '@react-native-harness/bridge';
|
|
2
|
+
import parseErrorStack from 'react-native/Libraries/Core/Devtools/parseErrorStack';
|
|
3
|
+
import symbolicateStackTrace from 'react-native/Libraries/Core/Devtools/symbolicateStackTrace';
|
|
4
|
+
|
|
5
|
+
export const getCodeFrame = async (error: Error): Promise<CodeFrame | null> => {
|
|
6
|
+
const parsedStack = parseErrorStack(error.stack);
|
|
7
|
+
const symbolicatedStack = await symbolicateStackTrace(parsedStack);
|
|
8
|
+
|
|
9
|
+
if (!symbolicatedStack.codeFrame) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Normalize optionality (null -> undefined)
|
|
14
|
+
return {
|
|
15
|
+
...symbolicatedStack.codeFrame,
|
|
16
|
+
location: symbolicatedStack.codeFrame.location
|
|
17
|
+
? {
|
|
18
|
+
...symbolicatedStack.codeFrame.location,
|
|
19
|
+
}
|
|
20
|
+
: undefined,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TestRunnerEvents,
|
|
3
|
+
TestCollectorEvents,
|
|
4
|
+
BundlerEvents,
|
|
5
|
+
} from '@react-native-harness/bridge';
|
|
6
|
+
import type { EventEmitter } from './emitter.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Attaches console logging to runtime events to provide progress information.
|
|
10
|
+
* This function handles all test run lifecycle events including start, progress, and completion.
|
|
11
|
+
*/
|
|
12
|
+
export const attachProgressLogger = (
|
|
13
|
+
events: EventEmitter<TestRunnerEvents | TestCollectorEvents | BundlerEvents>,
|
|
14
|
+
testPath: string
|
|
15
|
+
): void => {
|
|
16
|
+
// Log test run start
|
|
17
|
+
console.log(`🎯 Starting test run for: ${testPath}`);
|
|
18
|
+
|
|
19
|
+
// Handle all runtime events
|
|
20
|
+
events.addListener((event) => {
|
|
21
|
+
switch (event.type) {
|
|
22
|
+
case 'collection-started':
|
|
23
|
+
console.log(`📄 Collecting tests from: ${event.file}`);
|
|
24
|
+
break;
|
|
25
|
+
case 'collection-finished':
|
|
26
|
+
console.log(`✅ Test collection completed in ${event.duration}ms`);
|
|
27
|
+
break;
|
|
28
|
+
case 'module-bundling-started':
|
|
29
|
+
console.log(`📦 Bundling module: ${event.file}`);
|
|
30
|
+
break;
|
|
31
|
+
case 'module-bundling-finished':
|
|
32
|
+
console.log(`✅ Module bundling completed in ${event.duration}ms`);
|
|
33
|
+
break;
|
|
34
|
+
case 'file-started':
|
|
35
|
+
console.log(`🚀 Running tests in: ${event.file}`);
|
|
36
|
+
break;
|
|
37
|
+
case 'file-finished':
|
|
38
|
+
console.log(`📋 File completed in ${event.duration}ms: ${event.file}`);
|
|
39
|
+
break;
|
|
40
|
+
case 'suite-started':
|
|
41
|
+
console.log(`📦 Suite started: ${event.name}`);
|
|
42
|
+
break;
|
|
43
|
+
case 'suite-finished':
|
|
44
|
+
const suiteStatus =
|
|
45
|
+
event.status === 'passed'
|
|
46
|
+
? '✅'
|
|
47
|
+
: event.status === 'failed'
|
|
48
|
+
? '❌'
|
|
49
|
+
: '⏭️';
|
|
50
|
+
console.log(
|
|
51
|
+
`${suiteStatus} Suite "${event.name}" ${event.status} (${event.duration}ms)`
|
|
52
|
+
);
|
|
53
|
+
if (event.error) {
|
|
54
|
+
console.log(` Error: ${event.error.message}`);
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
case 'test-started':
|
|
58
|
+
console.log(` 🧪 Running: ${event.name}`);
|
|
59
|
+
break;
|
|
60
|
+
case 'test-finished':
|
|
61
|
+
const testStatus =
|
|
62
|
+
event.status === 'passed'
|
|
63
|
+
? '✅'
|
|
64
|
+
: event.status === 'failed'
|
|
65
|
+
? '❌'
|
|
66
|
+
: event.status === 'skipped'
|
|
67
|
+
? '⏭️'
|
|
68
|
+
: '📝';
|
|
69
|
+
console.log(` ${testStatus} ${event.name} (${event.duration}ms)`);
|
|
70
|
+
if (event.error) {
|
|
71
|
+
console.log(` Error: ${event.error.message}`);
|
|
72
|
+
if (event.error.codeFrame) {
|
|
73
|
+
console.log(` Code frame: ${event.error.codeFrame.content}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
console.log(`🔔 Event: ${(event as any).type}`, event);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Add completion and error logging through a wrapper
|
|
84
|
+
const originalEmit = events.emit;
|
|
85
|
+
let isCompleted = false;
|
|
86
|
+
|
|
87
|
+
events.emit = (event) => {
|
|
88
|
+
const result = originalEmit.call(events, event);
|
|
89
|
+
|
|
90
|
+
// Check if this is the last event to log completion
|
|
91
|
+
if (!isCompleted && event.type === 'file-finished') {
|
|
92
|
+
console.log(`🏁 Test run completed for: ${testPath}`);
|
|
93
|
+
isCompleted = true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return result;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/bundler/dev-server.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,QAAO,MAGlC,CAAC"}
|
package/dist/exports.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { UI } from './ui/UI.js';
|
|
2
|
-
export { getEntryComponent } from './getEntryComponent.js';
|
|
3
|
-
export * from './spy/index.js';
|
|
4
|
-
export * from './expect/index.js';
|
|
5
|
-
export * from './collector/index.js';
|
|
6
|
-
export * from './mocker/index.js';
|
|
7
|
-
//# sourceMappingURL=exports.d.ts.map
|
package/dist/exports.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
|
package/dist/exports.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEntryComponent.d.ts","sourceRoot":"","sources":["../src/getEntryComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAEpC,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,UAAU,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,iBAAiB,GAAI,WAAW,aAAa,QAMzD,CAAC"}
|
package/dist/logger.d.ts
DELETED
package/dist/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;oBACD,OAAO,EAAE;qBAGR,OAAO,EAAE;mBAGX,OAAO,EAAE;CAKzB,CAAC"}
|
package/dist/logger.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const verbose = global.RN_HARNESS.verbose;
|
|
2
|
-
export const logger = {
|
|
3
|
-
info: (...args) => {
|
|
4
|
-
console.info(...args);
|
|
5
|
-
},
|
|
6
|
-
error: (...args) => {
|
|
7
|
-
console.error(...args);
|
|
8
|
-
},
|
|
9
|
-
log: (...args) => {
|
|
10
|
-
if (verbose) {
|
|
11
|
-
console.log(...args);
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
};
|
package/dist/mock.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type ModuleId = number;
|
|
2
|
-
type Require = {
|
|
3
|
-
(moduleId: number): unknown;
|
|
4
|
-
};
|
|
5
|
-
declare global {
|
|
6
|
-
var __r: Require;
|
|
7
|
-
}
|
|
8
|
-
export type ModuleFactory = () => unknown;
|
|
9
|
-
export declare const mock: (moduleId: ModuleId, factory: ModuleFactory) => void;
|
|
10
|
-
export declare const clearMocks: () => void;
|
|
11
|
-
export declare const getMockRegistry: () => Map<number, ModuleFactory>;
|
|
12
|
-
export declare const getMockImplementation: (moduleId: number) => unknown | null;
|
|
13
|
-
export declare const requireActual: <T = any>(moduleId: ModuleId) => T;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=mock.d.ts.map
|
package/dist/mock.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../src/mock.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,MAAM,CAAC;AACvB,KAAK,OAAO,GAAG;IACb,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B,CAAC;AACF,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,GAAG,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC;AAO1C,eAAO,MAAM,IAAI,GAAI,UAAU,QAAQ,EAAE,SAAS,aAAa,KAAG,IAGjE,CAAC;AAEF,eAAO,MAAM,UAAU,QAAO,IAG7B,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,GAAG,CAAC,MAAM,EAAE,aAAa,CAE3D,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,OAAO,GAAG,IAalE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,GAAG,GAAG,EAAE,UAAU,QAAQ,KAAG,CAC5B,CAAC"}
|
package/dist/mock.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const mockRegistry = new Map();
|
|
2
|
-
const mockCache = new Map();
|
|
3
|
-
const originalRequire = global.__r;
|
|
4
|
-
export const mock = (moduleId, factory) => {
|
|
5
|
-
mockCache.delete(moduleId);
|
|
6
|
-
mockRegistry.set(moduleId, factory);
|
|
7
|
-
};
|
|
8
|
-
export const clearMocks = () => {
|
|
9
|
-
mockRegistry.clear();
|
|
10
|
-
mockCache.clear();
|
|
11
|
-
};
|
|
12
|
-
export const getMockRegistry = () => {
|
|
13
|
-
return mockRegistry;
|
|
14
|
-
};
|
|
15
|
-
export const getMockImplementation = (moduleId) => {
|
|
16
|
-
if (mockCache.has(moduleId)) {
|
|
17
|
-
return mockCache.get(moduleId);
|
|
18
|
-
}
|
|
19
|
-
const factory = mockRegistry.get(moduleId);
|
|
20
|
-
if (!factory) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const implementation = factory();
|
|
24
|
-
mockCache.set(moduleId, implementation);
|
|
25
|
-
return implementation;
|
|
26
|
-
};
|
|
27
|
-
export const requireActual = (moduleId) => originalRequire(moduleId);
|
|
28
|
-
const mockRequire = (moduleId) => {
|
|
29
|
-
const mockedModule = getMockImplementation(moduleId);
|
|
30
|
-
if (mockedModule) {
|
|
31
|
-
return mockedModule;
|
|
32
|
-
}
|
|
33
|
-
return originalRequire(moduleId);
|
|
34
|
-
};
|
|
35
|
-
Object.setPrototypeOf(mockRequire, Object.getPrototypeOf(originalRequire));
|
|
36
|
-
Object.defineProperties(mockRequire, Object.getOwnPropertyDescriptors(originalRequire));
|
|
37
|
-
global.__r = mockRequire;
|
package/dist/module.d.ts
DELETED
package/dist/module.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,WAAW,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAIlE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,KAAG,IAQhD,CAAC"}
|
package/dist/module.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
const METRO_URL = 'http://localhost:8081';
|
|
3
|
-
const getModuleUrl = (fileName) => {
|
|
4
|
-
const bundleName = fileName.split('.').slice(0, -1).join('.') + '.bundle';
|
|
5
|
-
return `${METRO_URL}/${bundleName}?modulesOnly=true&platform=${Platform.OS}`;
|
|
6
|
-
};
|
|
7
|
-
export const fetchModule = async (fileName) => {
|
|
8
|
-
const url = getModuleUrl(fileName);
|
|
9
|
-
const response = await fetch(url);
|
|
10
|
-
return response.text();
|
|
11
|
-
};
|
|
12
|
-
export const executeModule = (moduleJs) => {
|
|
13
|
-
const __rMatch = moduleJs.match(/__r\((\d+)\)/);
|
|
14
|
-
const __rParam = __rMatch[1];
|
|
15
|
-
// eslint-disable-next-line no-eval
|
|
16
|
-
eval(moduleJs);
|
|
17
|
-
// @ts-ignore - __r is injected by Metro bundler
|
|
18
|
-
__r(Number(__rParam));
|
|
19
|
-
};
|
package/dist/module.web.d.ts
DELETED
package/dist/module.web.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.web.d.ts","sourceRoot":"","sources":["../src/module.web.ts"],"names":[],"mappings":""}
|
package/dist/module.web.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// const context = require.context('../..', false, /\.test.tsx$/);
|
|
2
|
-
export {};
|
|
3
|
-
// export const fetchModule = async (fileName: string): Promise<string> => {
|
|
4
|
-
// return fileName;
|
|
5
|
-
// };
|
|
6
|
-
// export const executeModule = (moduleJs: string): void => {
|
|
7
|
-
// const modulePath = `./${moduleJs}`;
|
|
8
|
-
// if (!context.keys().includes(modulePath)) {
|
|
9
|
-
// throw new Error(`Module ${moduleJs} not found`);
|
|
10
|
-
// }
|
|
11
|
-
// return context(modulePath);
|
|
12
|
-
// };
|
package/dist/rntl/client.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/rntl/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGnE,eAAO,MAAM,SAAS,QAAO,YAU5B,CAAC"}
|
package/dist/rntl/client.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { state } from '../state.js';
|
|
2
|
-
export const getClient = () => {
|
|
3
|
-
const client = state.getState().client;
|
|
4
|
-
if (!client) {
|
|
5
|
-
throw new Error('Client not found. Are you sure you are running the test in the react-native-harness environment?');
|
|
6
|
-
}
|
|
7
|
-
return client;
|
|
8
|
-
};
|
package/dist/rntl/describe.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/rntl/describe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/rntl/describe.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { describe, test, it } from '../collector/functions.js';
|