@react-native-harness/runtime 1.0.0-alpha.21 → 1.0.0-alpha.22

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 (195) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +20 -2
  3. package/src/client/factory.ts +9 -2
  4. package/src/client/store.ts +16 -0
  5. package/src/expect/expect.ts +127 -0
  6. package/src/expect/index.ts +1 -123
  7. package/src/expect/matchers/toMatchImageSnapshot.ts +50 -0
  8. package/src/globals.ts +12 -0
  9. package/src/index.ts +1 -1
  10. package/src/render/TestComponentOverlay.tsx +22 -2
  11. package/src/render/index.ts +8 -6
  12. package/src/runner/context.ts +16 -0
  13. package/src/runner/factory.ts +7 -1
  14. package/src/runner/index.ts +5 -0
  15. package/src/runner/runSuite.ts +4 -0
  16. package/src/runner/types.ts +7 -1
  17. package/src/ui/ReadyScreen.tsx +1 -0
  18. package/.babelrc.js +0 -23
  19. package/assets/harness-module-system.js +0 -73
  20. package/dist/bundler/bundle.d.ts +0 -2
  21. package/dist/bundler/bundle.d.ts.map +0 -1
  22. package/dist/bundler/bundle.js +0 -21
  23. package/dist/bundler/errors.d.ts +0 -15
  24. package/dist/bundler/errors.d.ts.map +0 -1
  25. package/dist/bundler/errors.js +0 -29
  26. package/dist/bundler/evaluate.d.ts +0 -2
  27. package/dist/bundler/evaluate.d.ts.map +0 -1
  28. package/dist/bundler/evaluate.js +0 -18
  29. package/dist/bundler/factory.d.ts +0 -3
  30. package/dist/bundler/factory.d.ts.map +0 -1
  31. package/dist/bundler/factory.js +0 -36
  32. package/dist/bundler/index.d.ts +0 -4
  33. package/dist/bundler/index.d.ts.map +0 -1
  34. package/dist/bundler/index.js +0 -2
  35. package/dist/bundler/types.d.ts +0 -7
  36. package/dist/bundler/types.d.ts.map +0 -1
  37. package/dist/bundler/types.js +0 -1
  38. package/dist/client/factory.d.ts +0 -2
  39. package/dist/client/factory.d.ts.map +0 -1
  40. package/dist/client/factory.js +0 -69
  41. package/dist/client/getDeviceDescriptor.d.ts +0 -8
  42. package/dist/client/getDeviceDescriptor.d.ts.map +0 -1
  43. package/dist/client/getDeviceDescriptor.js +0 -32
  44. package/dist/client/getWSServer.d.ts +0 -2
  45. package/dist/client/getWSServer.d.ts.map +0 -1
  46. package/dist/client/getWSServer.js +0 -8
  47. package/dist/client/index.d.ts +0 -2
  48. package/dist/client/index.d.ts.map +0 -1
  49. package/dist/client/index.js +0 -1
  50. package/dist/client/setup-files.d.ts +0 -12
  51. package/dist/client/setup-files.d.ts.map +0 -1
  52. package/dist/client/setup-files.js +0 -60
  53. package/dist/collector/errors.d.ts +0 -8
  54. package/dist/collector/errors.d.ts.map +0 -1
  55. package/dist/collector/errors.js +0 -20
  56. package/dist/collector/factory.d.ts +0 -3
  57. package/dist/collector/factory.d.ts.map +0 -1
  58. package/dist/collector/factory.js +0 -25
  59. package/dist/collector/functions.d.ts +0 -22
  60. package/dist/collector/functions.d.ts.map +0 -1
  61. package/dist/collector/functions.js +0 -279
  62. package/dist/collector/index.d.ts +0 -5
  63. package/dist/collector/index.d.ts.map +0 -1
  64. package/dist/collector/index.js +0 -3
  65. package/dist/collector/types.d.ts +0 -10
  66. package/dist/collector/types.d.ts.map +0 -1
  67. package/dist/collector/types.js +0 -1
  68. package/dist/collector/validation.d.ts +0 -4
  69. package/dist/collector/validation.d.ts.map +0 -1
  70. package/dist/collector/validation.js +0 -15
  71. package/dist/constants.d.ts +0 -2
  72. package/dist/constants.d.ts.map +0 -1
  73. package/dist/constants.js +0 -1
  74. package/dist/disableHMRWhenReady.d.ts +0 -2
  75. package/dist/disableHMRWhenReady.d.ts.map +0 -1
  76. package/dist/disableHMRWhenReady.js +0 -20
  77. package/dist/entry-point.d.ts +0 -2
  78. package/dist/entry-point.d.ts.map +0 -1
  79. package/dist/entry-point.js +0 -4
  80. package/dist/errors.d.ts +0 -6
  81. package/dist/errors.d.ts.map +0 -1
  82. package/dist/errors.js +0 -13
  83. package/dist/expect/index.d.ts +0 -9
  84. package/dist/expect/index.d.ts.map +0 -1
  85. package/dist/expect/index.js +0 -73
  86. package/dist/expect/setup.d.ts +0 -2
  87. package/dist/expect/setup.d.ts.map +0 -1
  88. package/dist/expect/setup.js +0 -7
  89. package/dist/filtering/index.d.ts +0 -2
  90. package/dist/filtering/index.d.ts.map +0 -1
  91. package/dist/filtering/index.js +0 -1
  92. package/dist/filtering/testNameFilter.d.ts +0 -12
  93. package/dist/filtering/testNameFilter.d.ts.map +0 -1
  94. package/dist/filtering/testNameFilter.js +0 -56
  95. package/dist/globals.d.ts +0 -9
  96. package/dist/globals.d.ts.map +0 -1
  97. package/dist/globals.js +0 -7
  98. package/dist/index.d.ts +0 -11
  99. package/dist/index.d.ts.map +0 -1
  100. package/dist/initialize.d.ts +0 -2
  101. package/dist/initialize.d.ts.map +0 -1
  102. package/dist/initialize.js +0 -24
  103. package/dist/jest-mock.d.ts +0 -2
  104. package/dist/jest-mock.d.ts.map +0 -1
  105. package/dist/jest-mock.js +0 -25
  106. package/dist/mocker/index.d.ts +0 -2
  107. package/dist/mocker/index.d.ts.map +0 -1
  108. package/dist/mocker/index.js +0 -1
  109. package/dist/mocker/registry.d.ts +0 -6
  110. package/dist/mocker/registry.d.ts.map +0 -1
  111. package/dist/mocker/registry.js +0 -50
  112. package/dist/mocker/types.d.ts +0 -6
  113. package/dist/mocker/types.d.ts.map +0 -1
  114. package/dist/mocker/types.js +0 -1
  115. package/dist/namespace.d.ts +0 -18
  116. package/dist/namespace.d.ts.map +0 -1
  117. package/dist/namespace.js +0 -19
  118. package/dist/polyfills.d.ts +0 -11
  119. package/dist/polyfills.d.ts.map +0 -1
  120. package/dist/polyfills.js +0 -13
  121. package/dist/render/ErrorBoundary.d.ts +0 -17
  122. package/dist/render/ErrorBoundary.d.ts.map +0 -1
  123. package/dist/render/ErrorBoundary.js +0 -73
  124. package/dist/render/TestComponentOverlay.d.ts +0 -3
  125. package/dist/render/TestComponentOverlay.d.ts.map +0 -1
  126. package/dist/render/TestComponentOverlay.js +0 -36
  127. package/dist/render/cleanup.d.ts +0 -2
  128. package/dist/render/cleanup.d.ts.map +0 -1
  129. package/dist/render/cleanup.js +0 -6
  130. package/dist/render/index.d.ts +0 -6
  131. package/dist/render/index.d.ts.map +0 -1
  132. package/dist/render/index.js +0 -66
  133. package/dist/render/setup.d.ts +0 -2
  134. package/dist/render/setup.d.ts.map +0 -1
  135. package/dist/render/setup.js +0 -7
  136. package/dist/render/types.d.ts +0 -12
  137. package/dist/render/types.d.ts.map +0 -1
  138. package/dist/render/types.js +0 -1
  139. package/dist/runner/errors.d.ts +0 -11
  140. package/dist/runner/errors.d.ts.map +0 -1
  141. package/dist/runner/errors.js +0 -41
  142. package/dist/runner/factory.d.ts +0 -3
  143. package/dist/runner/factory.d.ts.map +0 -1
  144. package/dist/runner/factory.js +0 -22
  145. package/dist/runner/hooks.d.ts +0 -4
  146. package/dist/runner/hooks.d.ts.map +0 -1
  147. package/dist/runner/hooks.js +0 -39
  148. package/dist/runner/index.d.ts +0 -4
  149. package/dist/runner/index.d.ts.map +0 -1
  150. package/dist/runner/index.js +0 -2
  151. package/dist/runner/runSuite.d.ts +0 -4
  152. package/dist/runner/runSuite.d.ts.map +0 -1
  153. package/dist/runner/runSuite.js +0 -199
  154. package/dist/runner/types.d.ts +0 -13
  155. package/dist/runner/types.d.ts.map +0 -1
  156. package/dist/runner/types.js +0 -1
  157. package/dist/spy/index.d.ts +0 -2
  158. package/dist/spy/index.d.ts.map +0 -1
  159. package/dist/spy/index.js +0 -2
  160. package/dist/symbolicate.d.ts +0 -3
  161. package/dist/symbolicate.d.ts.map +0 -1
  162. package/dist/symbolicate.js +0 -19
  163. package/dist/tsconfig.lib.tsbuildinfo +0 -1
  164. package/dist/ui/ReadyScreen.d.ts +0 -2
  165. package/dist/ui/ReadyScreen.d.ts.map +0 -1
  166. package/dist/ui/ReadyScreen.js +0 -103
  167. package/dist/ui/WrongEnvironmentScreen.d.ts +0 -2
  168. package/dist/ui/WrongEnvironmentScreen.d.ts.map +0 -1
  169. package/dist/ui/WrongEnvironmentScreen.js +0 -79
  170. package/dist/ui/index.d.ts +0 -2
  171. package/dist/ui/index.d.ts.map +0 -1
  172. package/dist/ui/index.js +0 -3
  173. package/dist/ui/state.d.ts +0 -20
  174. package/dist/ui/state.d.ts.map +0 -1
  175. package/dist/ui/state.js +0 -28
  176. package/dist/utils/dev-server.d.ts +0 -2
  177. package/dist/utils/dev-server.d.ts.map +0 -1
  178. package/dist/utils/dev-server.js +0 -5
  179. package/dist/utils/emitter.d.ts +0 -16
  180. package/dist/utils/emitter.d.ts.map +0 -1
  181. package/dist/utils/emitter.js +0 -39
  182. package/dist/waitFor.d.ts +0 -21
  183. package/dist/waitFor.d.ts.map +0 -1
  184. package/dist/waitFor.js +0 -137
  185. package/eslint.config.mjs +0 -10
  186. package/src/__tests__/collector.test.ts +0 -553
  187. package/src/__tests__/error-handling.test.ts +0 -132
  188. package/src/__tests__/expect.test.ts +0 -627
  189. package/src/__tests__/initialize.test.ts +0 -24
  190. package/src/__tests__/spy.test.ts +0 -538
  191. package/tsconfig.json +0 -16
  192. package/tsconfig.lib.json +0 -33
  193. package/tsconfig.spec.json +0 -34
  194. package/tsconfig.tsbuildinfo +0 -1
  195. package/vite.config.ts +0 -27
@@ -1 +0,0 @@
1
- {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../src/initialize.ts"],"names":[],"mappings":""}
@@ -1,24 +0,0 @@
1
- import { getDeviceDescriptor } from './client/getDeviceDescriptor.js';
2
- import { getClient } from './client/index.js';
3
- import { disableHMRWhenReady } from './disableHMRWhenReady.js';
4
- import { setupJestMock } from './jest-mock.js';
5
- // Polyfill for EventTarget
6
- const Shim = require('event-target-shim');
7
- globalThis.Event = Shim.Event;
8
- globalThis.EventTarget = Shim.EventTarget;
9
- // Setup jest mock to warn users about using Jest APIs
10
- setupJestMock();
11
- // Turn off LogBox
12
- const { LogBox } = require('react-native');
13
- LogBox.ignoreAllLogs(true);
14
- // Turn off HMR
15
- const HMRClientModule = require('react-native/Libraries/Utilities/HMRClient');
16
- const HMRClient = 'default' in HMRClientModule ? HMRClientModule.default : HMRClientModule;
17
- // Wait for HMRClient to be initialized
18
- setTimeout(() => {
19
- void disableHMRWhenReady(() => HMRClient.disable(), 50).then(() => getClient().then((client) => client.rpc.reportReady(getDeviceDescriptor())));
20
- });
21
- // Re-throw fatal errors
22
- ErrorUtils.setGlobalHandler((error) => {
23
- throw error;
24
- });
@@ -1,2 +0,0 @@
1
- export declare const setupJestMock: () => void;
2
- //# sourceMappingURL=jest-mock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jest-mock.d.ts","sourceRoot":"","sources":["../src/jest-mock.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,QAAO,IA8BhC,CAAC"}
package/dist/jest-mock.js DELETED
@@ -1,25 +0,0 @@
1
- // Mock jest global to warn users about using Jest APIs in Harness tests
2
- export const setupJestMock = () => {
3
- function throwError() {
4
- throw new Error(`Jest globals are not available in Harness tests. Import from 'react-native-harness' instead (e.g., import { harness } from 'react-native-harness'; harness.fn())`);
5
- }
6
- const jestMock = new Proxy({}, {
7
- get() {
8
- throwError();
9
- },
10
- set() {
11
- throwError();
12
- },
13
- has() {
14
- throwError();
15
- },
16
- ownKeys() {
17
- throwError();
18
- },
19
- });
20
- Object.defineProperty(globalThis, 'jest', {
21
- value: jestMock,
22
- writable: false,
23
- configurable: false,
24
- });
25
- };
@@ -1,2 +0,0 @@
1
- export { mock, requireActual, unmock, resetModules, } from './registry.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mocker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,aAAa,EACb,MAAM,EACN,YAAY,GACb,MAAM,eAAe,CAAC"}
@@ -1 +0,0 @@
1
- export { mock, requireActual, unmock, resetModules, } from './registry.js';
@@ -1,6 +0,0 @@
1
- import { ModuleFactory } from './types.js';
2
- export declare const mock: (moduleId: string, factory: ModuleFactory) => void;
3
- export declare const requireActual: <T = any>(moduleId: string) => T;
4
- export declare const unmock: (moduleId: string) => void;
5
- export declare const resetModules: () => void;
6
- //# sourceMappingURL=registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/mocker/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AAO9D,eAAO,MAAM,IAAI,GAAI,UAAU,MAAM,EAAE,SAAS,aAAa,KAAG,IAG/D,CAAC;AAmBF,eAAO,MAAM,aAAa,GAAI,CAAC,GAAG,GAAG,EAAE,UAAU,MAAM,KAAG,CAEH,CAAC;AAExD,eAAO,MAAM,MAAM,GAAI,UAAU,MAAM,SAGtC,CAAC;AAEF,eAAO,MAAM,YAAY,QAAO,IAG/B,CAAC"}
@@ -1,50 +0,0 @@
1
- const modulesCache = new Map();
2
- const mockRegistry = new Map();
3
- const originalRequire = global.__r;
4
- export const mock = (moduleId, factory) => {
5
- modulesCache.delete(moduleId);
6
- mockRegistry.set(moduleId, factory);
7
- };
8
- const isModuleMocked = (moduleId) => {
9
- return mockRegistry.has(moduleId);
10
- };
11
- const getMockImplementation = (moduleId) => {
12
- const factory = mockRegistry.get(moduleId);
13
- if (!factory) {
14
- return null;
15
- }
16
- const implementation = factory();
17
- modulesCache.set(moduleId, implementation);
18
- return implementation;
19
- };
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- export const requireActual = (moduleId) =>
22
- // babel plugin will transform 'moduleId' to a number
23
- originalRequire(moduleId);
24
- export const unmock = (moduleId) => {
25
- mockRegistry.delete(moduleId);
26
- modulesCache.delete(moduleId);
27
- };
28
- export const resetModules = () => {
29
- modulesCache.clear();
30
- mockRegistry.clear();
31
- };
32
- const mockRequire = (moduleId) => {
33
- // babel plugin will transform 'moduleId' to a number
34
- const moduleIdNumber = moduleId;
35
- const cachedModule = modulesCache.get(moduleIdNumber);
36
- if (cachedModule) {
37
- return cachedModule;
38
- }
39
- if (isModuleMocked(moduleIdNumber)) {
40
- const mockedModule = getMockImplementation(moduleIdNumber);
41
- modulesCache.set(moduleIdNumber, mockedModule);
42
- return mockedModule;
43
- }
44
- const originalModule = originalRequire(moduleIdNumber);
45
- modulesCache.set(moduleIdNumber, originalModule);
46
- return originalModule;
47
- };
48
- Object.setPrototypeOf(mockRequire, Object.getPrototypeOf(originalRequire));
49
- Object.defineProperties(mockRequire, Object.getOwnPropertyDescriptors(originalRequire));
50
- global.__r = mockRequire;
@@ -1,6 +0,0 @@
1
- export type ModuleId = number;
2
- export type Require = {
3
- (moduleId: number): unknown;
4
- };
5
- export type ModuleFactory = () => unknown;
6
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mocker/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,OAAO,GAAG;IACpB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- import { spyOn, fn, clearAllMocks, resetAllMocks, restoreAllMocks } from './spy/index.js';
2
- import { mock, unmock, requireActual, resetModules } from './mocker/index.js';
3
- import { waitFor, waitUntil } from './waitFor.js';
4
- export type HarnessNamespace = {
5
- spyOn: typeof spyOn;
6
- fn: typeof fn;
7
- mock: typeof mock;
8
- unmock: typeof unmock;
9
- requireActual: typeof requireActual;
10
- clearAllMocks: typeof clearAllMocks;
11
- resetAllMocks: typeof resetAllMocks;
12
- restoreAllMocks: typeof restoreAllMocks;
13
- resetModules: typeof resetModules;
14
- waitFor: typeof waitFor;
15
- waitUntil: typeof waitUntil;
16
- };
17
- export declare const harness: HarnessNamespace;
18
- //# sourceMappingURL=namespace.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../src/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,EAAE,EACF,aAAa,EACb,aAAa,EACb,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,EAAE,EAAE,OAAO,EAAE,CAAC;IACd,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,MAAM,EAAE,OAAO,MAAM,CAAC;IACtB,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,eAAe,EAAE,OAAO,eAAe,CAAC;IACxC,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,SAAS,CAAC;CAC7B,CAAC;AAkBF,eAAO,MAAM,OAAO,kBAA2B,CAAC"}
package/dist/namespace.js DELETED
@@ -1,19 +0,0 @@
1
- import { spyOn, fn, clearAllMocks, resetAllMocks, restoreAllMocks, } from './spy/index.js';
2
- import { mock, unmock, requireActual, resetModules } from './mocker/index.js';
3
- import { waitFor, waitUntil } from './waitFor.js';
4
- const createHarnessNamespace = () => {
5
- return {
6
- spyOn,
7
- fn,
8
- mock,
9
- unmock,
10
- requireActual,
11
- clearAllMocks,
12
- resetAllMocks,
13
- restoreAllMocks,
14
- resetModules,
15
- waitFor,
16
- waitUntil,
17
- };
18
- };
19
- export const harness = createHarnessNamespace();
@@ -1,11 +0,0 @@
1
- /**
2
- * Polyfills for ES2022+ features not supported by JSC (JavaScriptCore).
3
- *
4
- * JSC, used in React Native when Hermes is disabled, doesn't support
5
- * Object.hasOwn (ES2022). This causes runtime errors when @vitest/expect
6
- * v4.x initializes.
7
- *
8
- * This polyfill must be loaded before any code that uses Object.hasOwn.
9
- */
10
- export {};
11
- //# sourceMappingURL=polyfills.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"polyfills.d.ts","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
package/dist/polyfills.js DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Polyfills for ES2022+ features not supported by JSC (JavaScriptCore).
3
- *
4
- * JSC, used in React Native when Hermes is disabled, doesn't support
5
- * Object.hasOwn (ES2022). This causes runtime errors when @vitest/expect
6
- * v4.x initializes.
7
- *
8
- * This polyfill must be loaded before any code that uses Object.hasOwn.
9
- */
10
- if (typeof Object.hasOwn !== 'function') {
11
- Object.hasOwn = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
12
- }
13
- export {};
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- type ErrorBoundaryProps = {
3
- children: React.ReactNode;
4
- };
5
- type ErrorBoundaryState = {
6
- hasError: boolean;
7
- error: Error | null;
8
- };
9
- export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
10
- constructor(props: ErrorBoundaryProps);
11
- static getDerivedStateFromError(error: Error): ErrorBoundaryState;
12
- componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
13
- componentDidUpdate(prevProps: ErrorBoundaryProps): void;
14
- render(): React.ReactNode;
15
- }
16
- export {};
17
- //# sourceMappingURL=ErrorBoundary.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/render/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,qBAAa,aAAc,SAAQ,KAAK,CAAC,SAAS,CAChD,kBAAkB,EAClB,kBAAkB,CACnB;gBACa,KAAK,EAAE,kBAAkB;IAKrC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB;IAIxD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI;IAIjE,kBAAkB,CAAC,SAAS,EAAE,kBAAkB,GAAG,IAAI;IAOvD,MAAM,IAAI,KAAK,CAAC,SAAS;CAwBnC"}
@@ -1,73 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from 'react';
3
- import { View, Text, StyleSheet, ScrollView } from 'react-native';
4
- export class ErrorBoundary extends React.Component {
5
- constructor(props) {
6
- super(props);
7
- this.state = { hasError: false, error: null };
8
- }
9
- static getDerivedStateFromError(error) {
10
- return { hasError: true, error };
11
- }
12
- componentDidCatch(error, errorInfo) {
13
- console.error('Error caught by ErrorBoundary:', error, errorInfo);
14
- }
15
- componentDidUpdate(prevProps) {
16
- // Reset error state when children change (new component rendered)
17
- if (prevProps.children !== this.props.children && this.state.hasError) {
18
- this.setState({ hasError: false, error: null });
19
- }
20
- }
21
- render() {
22
- if (this.state.hasError && this.state.error) {
23
- return (_jsx(View, { style: styles.errorContainer, children: _jsxs(View, { style: styles.errorContent, children: [_jsx(Text, { style: styles.errorTitle, children: "Component Error" }), _jsx(Text, { style: styles.errorSubtitle, children: "The rendered component threw an error:" }), _jsxs(ScrollView, { style: styles.errorScrollView, children: [_jsx(Text, { style: styles.errorMessage, children: this.state.error.message }), this.state.error.stack && (_jsx(Text, { style: styles.errorStack, children: this.state.error.stack }))] })] }) }));
24
- }
25
- return this.props.children;
26
- }
27
- }
28
- const styles = StyleSheet.create({
29
- errorContainer: {
30
- flex: 1,
31
- backgroundColor: 'rgba(220, 38, 38, 0.1)',
32
- justifyContent: 'center',
33
- alignItems: 'center',
34
- padding: 20,
35
- },
36
- errorContent: {
37
- backgroundColor: '#1f2937',
38
- borderRadius: 12,
39
- padding: 20,
40
- maxWidth: 500,
41
- width: '100%',
42
- maxHeight: '80%',
43
- borderWidth: 2,
44
- borderColor: '#dc2626',
45
- },
46
- errorTitle: {
47
- fontSize: 24,
48
- fontWeight: '700',
49
- color: '#dc2626',
50
- marginBottom: 8,
51
- },
52
- errorSubtitle: {
53
- fontSize: 14,
54
- color: '#9ca3af',
55
- marginBottom: 16,
56
- },
57
- errorScrollView: {
58
- maxHeight: 400,
59
- },
60
- errorMessage: {
61
- fontSize: 16,
62
- fontWeight: '600',
63
- color: '#fca5a5',
64
- marginBottom: 12,
65
- fontFamily: 'Courier',
66
- },
67
- errorStack: {
68
- fontSize: 12,
69
- color: '#d1d5db',
70
- fontFamily: 'Courier',
71
- lineHeight: 18,
72
- },
73
- });
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const TestComponentOverlay: () => React.ReactElement | null;
3
- //# sourceMappingURL=TestComponentOverlay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TestComponentOverlay.d.ts","sourceRoot":"","sources":["../../src/render/TestComponentOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAMzC,eAAO,MAAM,oBAAoB,QAAO,KAAK,CAAC,YAAY,GAAG,IAgC5D,CAAC"}
@@ -1,36 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect } from 'react';
3
- import { View, StyleSheet } from 'react-native';
4
- import { useRenderedElement } from '../ui/state.js';
5
- import { store } from '../ui/state.js';
6
- import { ErrorBoundary } from './ErrorBoundary.js';
7
- export const TestComponentOverlay = () => {
8
- const { element, key } = useRenderedElement();
9
- useEffect(() => {
10
- // Call onRenderCallback when element changes
11
- const callback = store.getState().onRenderCallback;
12
- if (callback) {
13
- callback();
14
- store.getState().setOnRenderCallback(null);
15
- }
16
- }, [element]);
17
- if (!element) {
18
- return null;
19
- }
20
- const handleLayout = () => {
21
- const callback = store.getState().onLayoutCallback;
22
- if (callback) {
23
- callback();
24
- // Clear the callback after calling it
25
- store.getState().setOnLayoutCallback(null);
26
- }
27
- };
28
- return (_jsx(View, { style: styles.overlay, onLayout: handleLayout, children: _jsx(ErrorBoundary, { children: element }) }, key));
29
- };
30
- const styles = StyleSheet.create({
31
- overlay: {
32
- ...StyleSheet.absoluteFillObject,
33
- backgroundColor: '#0a1628',
34
- zIndex: 1000,
35
- },
36
- });
@@ -1,2 +0,0 @@
1
- export declare const cleanup: () => void;
2
- //# sourceMappingURL=cleanup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/render/cleanup.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,QAAO,IAI1B,CAAC"}
@@ -1,6 +0,0 @@
1
- import { store } from '../ui/state.js';
2
- export const cleanup = () => {
3
- store.getState().setRenderedElement(null);
4
- store.getState().setOnLayoutCallback(null);
5
- store.getState().setOnRenderCallback(null);
6
- };
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import type { RenderResult, RenderOptions } from './types.js';
3
- export declare const render: (element: React.ReactElement, options?: RenderOptions) => Promise<RenderResult>;
4
- export { cleanup } from './cleanup.js';
5
- export type { RenderResult, RenderOptions } from './types.js';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAY9D,eAAO,MAAM,MAAM,GACjB,SAAS,KAAK,CAAC,YAAY,EAC3B,UAAS,aAAkB,KAC1B,OAAO,CAAC,YAAY,CA2EtB,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
@@ -1,66 +0,0 @@
1
- import React from 'react';
2
- import { store } from '../ui/state.js';
3
- const wrapElement = (element, wrapper) => {
4
- if (!wrapper) {
5
- return element;
6
- }
7
- return React.createElement(wrapper, { children: element });
8
- };
9
- export const render = async (element, options = {}) => {
10
- const { timeout = 1000, wrapper } = options;
11
- // If an element is already rendered, unmount it first
12
- if (store.getState().renderedElement !== null) {
13
- store.getState().setRenderedElement(null);
14
- store.getState().setOnLayoutCallback(null);
15
- store.getState().setOnRenderCallback(null);
16
- }
17
- // Create a promise that resolves when the element is laid out
18
- const layoutPromise = new Promise((resolve, reject) => {
19
- const timeoutId = setTimeout(() => {
20
- store.getState().setOnLayoutCallback(null);
21
- reject(new Error(`Render timeout: Element did not mount within ${timeout}ms`));
22
- }, timeout);
23
- store.getState().setOnLayoutCallback(() => {
24
- clearTimeout(timeoutId);
25
- resolve();
26
- });
27
- });
28
- // Wrap and set the element in state (key is generated automatically)
29
- const wrappedElement = wrapElement(element, wrapper);
30
- store.getState().setRenderedElement(wrappedElement);
31
- // Wait for layout
32
- await layoutPromise;
33
- const rerender = async (newElement) => {
34
- if (store.getState().renderedElement === null) {
35
- throw new Error('No element is currently rendered. Call render() first.');
36
- }
37
- // Create a promise that resolves when the element is re-rendered
38
- const renderPromise = new Promise((resolve, reject) => {
39
- const timeoutId = setTimeout(() => {
40
- store.getState().setOnRenderCallback(null);
41
- reject(new Error(`Rerender timeout: Element did not update within ${timeout}ms`));
42
- }, timeout);
43
- store.getState().setOnRenderCallback(() => {
44
- clearTimeout(timeoutId);
45
- resolve();
46
- });
47
- });
48
- const wrappedNewElement = wrapElement(newElement, wrapper);
49
- store.getState().updateRenderedElement(wrappedNewElement);
50
- // Wait for render
51
- await renderPromise;
52
- };
53
- const unmount = () => {
54
- if (store.getState().renderedElement === null) {
55
- return;
56
- }
57
- store.getState().setRenderedElement(null);
58
- store.getState().setOnLayoutCallback(null);
59
- store.getState().setOnRenderCallback(null);
60
- };
61
- return {
62
- rerender,
63
- unmount,
64
- };
65
- };
66
- export { cleanup } from './cleanup.js';
@@ -1,2 +0,0 @@
1
- export declare const setup: () => void;
2
- //# sourceMappingURL=setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/render/setup.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,YAIjB,CAAC"}
@@ -1,7 +0,0 @@
1
- import { afterEach } from '../collector/functions.js';
2
- import { cleanup } from './cleanup.js';
3
- export const setup = () => {
4
- afterEach(() => {
5
- cleanup();
6
- });
7
- };
@@ -1,12 +0,0 @@
1
- import type React from 'react';
2
- export type RenderResult = {
3
- rerender: (element: React.ReactElement) => Promise<void>;
4
- unmount: () => void;
5
- };
6
- export type RenderOptions = {
7
- timeout?: number;
8
- wrapper?: React.ComponentType<{
9
- children: React.ReactNode;
10
- }>;
11
- };
12
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/render/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;CAC9D,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import type { SerializedError, CodeFrame } from '@react-native-harness/bridge';
2
- export declare class TestExecutionError extends Error {
3
- file: string;
4
- suite: string;
5
- test: string;
6
- codeFrame?: CodeFrame;
7
- constructor(error: unknown, file: string, suite: string, test: string, codeFrame?: CodeFrame);
8
- toSerializedJSON(): SerializedError;
9
- }
10
- export declare const getTestExecutionError: (error: unknown, file: string, suite: string, test: string) => Promise<TestExecutionError>;
11
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/runner/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG/E,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;gBAGpB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,SAAS;IAWvB,gBAAgB,IAAI,eAAe;CAapC;AAED,eAAO,MAAM,qBAAqB,GAChC,OAAO,OAAO,EACd,MAAM,MAAM,EACZ,OAAO,MAAM,EACb,MAAM,MAAM,KACX,OAAO,CAAC,kBAAkB,CAe5B,CAAC"}
@@ -1,41 +0,0 @@
1
- import { getCodeFrame } from '../symbolicate.js';
2
- export class TestExecutionError extends Error {
3
- file;
4
- suite;
5
- test;
6
- codeFrame;
7
- constructor(error, file, suite, test, codeFrame) {
8
- super('Test execution error');
9
- this.name = 'TestExecutionError';
10
- this.file = file;
11
- this.suite = suite;
12
- this.test = test;
13
- this.cause = error;
14
- this.codeFrame = codeFrame;
15
- }
16
- toSerializedJSON() {
17
- const causeName = this.cause instanceof Error ? this.cause.name : 'Unknown name';
18
- const causeMessage = this.cause instanceof Error ? this.cause.message : 'Unknown message';
19
- const causeCodeFrame = this.codeFrame;
20
- return {
21
- name: causeName,
22
- message: causeMessage,
23
- codeFrame: causeCodeFrame,
24
- };
25
- }
26
- }
27
- export const getTestExecutionError = async (error, file, suite, test) => {
28
- try {
29
- if (error instanceof Error) {
30
- const codeFrame = await getCodeFrame(error);
31
- if (codeFrame) {
32
- return new TestExecutionError(error, file, suite, test, codeFrame);
33
- }
34
- }
35
- return new TestExecutionError(error, file, suite, test);
36
- }
37
- catch (error) {
38
- // If the stack cannot be symbolicated, return the original error
39
- return new TestExecutionError(error, file, suite, test);
40
- }
41
- };
@@ -1,3 +0,0 @@
1
- import { TestRunner } from './types.js';
2
- export declare const getTestRunner: () => TestRunner;
3
- //# sourceMappingURL=factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/runner/factory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,eAAO,MAAM,aAAa,QAAO,UAsBhC,CAAC"}
@@ -1,22 +0,0 @@
1
- import { getEmitter } from '../utils/emitter.js';
2
- import { runSuite } from './runSuite.js';
3
- export const getTestRunner = () => {
4
- const events = getEmitter();
5
- return {
6
- events,
7
- run: async (testSuite, testFilePath) => {
8
- const result = await runSuite(testSuite, {
9
- events,
10
- testFilePath,
11
- });
12
- // If coverage is enabled, there will be a global variable called __coverage__
13
- if ('__coverage__' in global && !!global.__coverage__) {
14
- result.coverage = global.__coverage__;
15
- }
16
- return result;
17
- },
18
- dispose: () => {
19
- events.clearAllListeners();
20
- },
21
- };
22
- };
@@ -1,4 +0,0 @@
1
- import type { TestSuite } from '@react-native-harness/bridge';
2
- export type HookType = 'beforeEach' | 'afterEach' | 'beforeAll' | 'afterAll';
3
- export declare const runHooks: (suite: TestSuite, hookType: HookType) => Promise<void>;
4
- //# sourceMappingURL=hooks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/runner/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC;AAuC7E,eAAO,MAAM,QAAQ,GACnB,OAAO,SAAS,EAChB,UAAU,QAAQ,KACjB,OAAO,CAAC,IAAI,CAMd,CAAC"}
@@ -1,39 +0,0 @@
1
- const collectInheritedHooks = (suite, hookType) => {
2
- const hooks = [];
3
- const suiteChain = [];
4
- // Collect all suites from current to root
5
- let currentSuite = suite;
6
- while (currentSuite) {
7
- suiteChain.push(currentSuite);
8
- currentSuite = currentSuite.parent;
9
- }
10
- if (hookType === 'beforeEach' || hookType === 'beforeAll') {
11
- // For beforeEach/beforeAll: run parent hooks first (reverse the chain)
12
- for (let i = suiteChain.length - 1; i >= 0; i--) {
13
- if (hookType === 'beforeEach') {
14
- hooks.push(...suiteChain[i].beforeEach);
15
- }
16
- else {
17
- hooks.push(...suiteChain[i].beforeAll);
18
- }
19
- }
20
- }
21
- else {
22
- // For afterEach/afterAll: run child hooks first (use chain as-is)
23
- for (const suiteInChain of suiteChain) {
24
- if (hookType === 'afterEach') {
25
- hooks.push(...suiteInChain.afterEach);
26
- }
27
- else {
28
- hooks.push(...suiteInChain.afterAll);
29
- }
30
- }
31
- }
32
- return hooks;
33
- };
34
- export const runHooks = async (suite, hookType) => {
35
- const hooks = collectInheritedHooks(suite, hookType);
36
- for (const hook of hooks) {
37
- await hook();
38
- }
39
- };