@react-native-harness/runtime 1.0.0-canary.1764675030942 → 1.0.0-canary.1766225407244

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/collection.d.ts +39 -0
  2. package/dist/collection.d.ts.map +1 -0
  3. package/dist/collection.js +224 -0
  4. package/dist/getEntryComponent.d.ts +6 -0
  5. package/dist/getEntryComponent.d.ts.map +1 -0
  6. package/dist/getEntryComponent.js +6 -0
  7. package/dist/module.d.ts +3 -0
  8. package/dist/module.d.ts.map +1 -0
  9. package/dist/module.js +26 -0
  10. package/dist/module.web.d.ts +2 -0
  11. package/dist/module.web.d.ts.map +1 -0
  12. package/dist/module.web.js +12 -0
  13. package/dist/package.json +37 -0
  14. package/dist/rntl/client.d.ts +3 -0
  15. package/dist/rntl/client.d.ts.map +1 -0
  16. package/dist/rntl/client.js +8 -0
  17. package/{out-tsc/vitest/src/collector/functions.d.ts → dist/rntl/describe.d.ts} +21 -4
  18. package/dist/rntl/describe.d.ts.map +1 -0
  19. package/dist/rntl/describe.js +216 -0
  20. package/dist/rntl/expect.d.ts +11 -0
  21. package/dist/rntl/expect.d.ts.map +1 -0
  22. package/dist/rntl/expect.js +19 -0
  23. package/dist/rntl/fn.d.ts +2 -0
  24. package/dist/rntl/fn.d.ts.map +1 -0
  25. package/dist/rntl/fn.js +1 -0
  26. package/dist/rntl/render.d.ts +4 -0
  27. package/dist/rntl/render.d.ts.map +1 -0
  28. package/dist/rntl/render.js +11 -0
  29. package/dist/rntl/screen.d.ts +45 -0
  30. package/dist/rntl/screen.d.ts.map +1 -0
  31. package/dist/rntl/screen.js +31 -0
  32. package/dist/rntl/userEvent.d.ts +22 -0
  33. package/dist/rntl/userEvent.d.ts.map +1 -0
  34. package/dist/rntl/userEvent.js +19 -0
  35. package/dist/runner.d.ts +4 -0
  36. package/dist/runner.d.ts.map +1 -0
  37. package/dist/runner.js +115 -0
  38. package/{out-tsc/vitest/src/client/factory.d.ts → dist/runtime.d.ts} +1 -1
  39. package/dist/runtime.d.ts.map +1 -0
  40. package/dist/runtime.js +39 -0
  41. package/dist/state.d.ts +25 -0
  42. package/dist/state.d.ts.map +1 -0
  43. package/dist/state.js +37 -0
  44. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  45. package/dist/ui/UI.d.ts +13 -0
  46. package/dist/ui/UI.d.ts.map +1 -0
  47. package/dist/ui/UI.js +121 -0
  48. package/package.json +2 -6
  49. package/dist/client/store.d.ts +0 -4
  50. package/dist/client/store.d.ts.map +0 -1
  51. package/dist/client/store.js +0 -10
  52. package/dist/expect/expect.d.ts +0 -9
  53. package/dist/expect/expect.d.ts.map +0 -1
  54. package/dist/expect/expect.js +0 -77
  55. package/dist/expect/matchers/toMatchImageSnapshot.d.ts +0 -12
  56. package/dist/expect/matchers/toMatchImageSnapshot.d.ts.map +0 -1
  57. package/dist/expect/matchers/toMatchImageSnapshot.js +0 -11
  58. package/dist/render/queries.d.ts +0 -7
  59. package/dist/render/queries.d.ts.map +0 -1
  60. package/dist/render/queries.js +0 -99
  61. package/dist/runner/context.d.ts +0 -10
  62. package/dist/runner/context.d.ts.map +0 -1
  63. package/dist/runner/context.js +0 -6
  64. package/dist/screen/index.d.ts +0 -8
  65. package/dist/screen/index.d.ts.map +0 -1
  66. package/dist/screen/index.js +0 -18
  67. package/dist/userEvent/index.d.ts +0 -6
  68. package/dist/userEvent/index.d.ts.map +0 -1
  69. package/dist/userEvent/index.js +0 -10
  70. package/out-tsc/vitest/src/__tests__/collector.test.d.ts +0 -2
  71. package/out-tsc/vitest/src/__tests__/collector.test.d.ts.map +0 -1
  72. package/out-tsc/vitest/src/__tests__/error-handling.test.d.ts +0 -2
  73. package/out-tsc/vitest/src/__tests__/error-handling.test.d.ts.map +0 -1
  74. package/out-tsc/vitest/src/__tests__/expect.test.d.ts +0 -2
  75. package/out-tsc/vitest/src/__tests__/expect.test.d.ts.map +0 -1
  76. package/out-tsc/vitest/src/__tests__/spy.test.d.ts +0 -2
  77. package/out-tsc/vitest/src/__tests__/spy.test.d.ts.map +0 -1
  78. package/out-tsc/vitest/src/bundler/bundle.d.ts +0 -2
  79. package/out-tsc/vitest/src/bundler/bundle.d.ts.map +0 -1
  80. package/out-tsc/vitest/src/bundler/errors.d.ts +0 -15
  81. package/out-tsc/vitest/src/bundler/errors.d.ts.map +0 -1
  82. package/out-tsc/vitest/src/bundler/evaluate.d.ts +0 -2
  83. package/out-tsc/vitest/src/bundler/evaluate.d.ts.map +0 -1
  84. package/out-tsc/vitest/src/bundler/factory.d.ts +0 -3
  85. package/out-tsc/vitest/src/bundler/factory.d.ts.map +0 -1
  86. package/out-tsc/vitest/src/bundler/index.d.ts +0 -4
  87. package/out-tsc/vitest/src/bundler/index.d.ts.map +0 -1
  88. package/out-tsc/vitest/src/bundler/types.d.ts +0 -7
  89. package/out-tsc/vitest/src/bundler/types.d.ts.map +0 -1
  90. package/out-tsc/vitest/src/client/factory.d.ts.map +0 -1
  91. package/out-tsc/vitest/src/client/getDeviceDescriptor.d.ts +0 -8
  92. package/out-tsc/vitest/src/client/getDeviceDescriptor.d.ts.map +0 -1
  93. package/out-tsc/vitest/src/client/getWSServer.d.ts +0 -2
  94. package/out-tsc/vitest/src/client/getWSServer.d.ts.map +0 -1
  95. package/out-tsc/vitest/src/client/index.d.ts +0 -2
  96. package/out-tsc/vitest/src/client/index.d.ts.map +0 -1
  97. package/out-tsc/vitest/src/client/setup-files.d.ts +0 -12
  98. package/out-tsc/vitest/src/client/setup-files.d.ts.map +0 -1
  99. package/out-tsc/vitest/src/client/store.d.ts +0 -4
  100. package/out-tsc/vitest/src/client/store.d.ts.map +0 -1
  101. package/out-tsc/vitest/src/collector/errors.d.ts +0 -8
  102. package/out-tsc/vitest/src/collector/errors.d.ts.map +0 -1
  103. package/out-tsc/vitest/src/collector/factory.d.ts +0 -3
  104. package/out-tsc/vitest/src/collector/factory.d.ts.map +0 -1
  105. package/out-tsc/vitest/src/collector/functions.d.ts.map +0 -1
  106. package/out-tsc/vitest/src/collector/index.d.ts +0 -5
  107. package/out-tsc/vitest/src/collector/index.d.ts.map +0 -1
  108. package/out-tsc/vitest/src/collector/types.d.ts +0 -10
  109. package/out-tsc/vitest/src/collector/types.d.ts.map +0 -1
  110. package/out-tsc/vitest/src/collector/validation.d.ts +0 -4
  111. package/out-tsc/vitest/src/collector/validation.d.ts.map +0 -1
  112. package/out-tsc/vitest/src/constants.d.ts +0 -2
  113. package/out-tsc/vitest/src/constants.d.ts.map +0 -1
  114. package/out-tsc/vitest/src/entry-point.d.ts +0 -2
  115. package/out-tsc/vitest/src/entry-point.d.ts.map +0 -1
  116. package/out-tsc/vitest/src/errors.d.ts +0 -6
  117. package/out-tsc/vitest/src/errors.d.ts.map +0 -1
  118. package/out-tsc/vitest/src/expect/index.d.ts +0 -14
  119. package/out-tsc/vitest/src/expect/index.d.ts.map +0 -1
  120. package/out-tsc/vitest/src/expect/matchers/toMatchImageSnapshot.d.ts +0 -7
  121. package/out-tsc/vitest/src/expect/matchers/toMatchImageSnapshot.d.ts.map +0 -1
  122. package/out-tsc/vitest/src/expect/setup.d.ts +0 -2
  123. package/out-tsc/vitest/src/expect/setup.d.ts.map +0 -1
  124. package/out-tsc/vitest/src/filtering/index.d.ts +0 -2
  125. package/out-tsc/vitest/src/filtering/index.d.ts.map +0 -1
  126. package/out-tsc/vitest/src/filtering/testNameFilter.d.ts +0 -12
  127. package/out-tsc/vitest/src/filtering/testNameFilter.d.ts.map +0 -1
  128. package/out-tsc/vitest/src/globals.d.ts +0 -8
  129. package/out-tsc/vitest/src/globals.d.ts.map +0 -1
  130. package/out-tsc/vitest/src/index.d.ts +0 -13
  131. package/out-tsc/vitest/src/index.d.ts.map +0 -1
  132. package/out-tsc/vitest/src/initialize.d.ts +0 -2
  133. package/out-tsc/vitest/src/initialize.d.ts.map +0 -1
  134. package/out-tsc/vitest/src/jest-mock.d.ts +0 -2
  135. package/out-tsc/vitest/src/jest-mock.d.ts.map +0 -1
  136. package/out-tsc/vitest/src/mocker/index.d.ts +0 -2
  137. package/out-tsc/vitest/src/mocker/index.d.ts.map +0 -1
  138. package/out-tsc/vitest/src/mocker/registry.d.ts +0 -7
  139. package/out-tsc/vitest/src/mocker/registry.d.ts.map +0 -1
  140. package/out-tsc/vitest/src/mocker/types.d.ts +0 -6
  141. package/out-tsc/vitest/src/mocker/types.d.ts.map +0 -1
  142. package/out-tsc/vitest/src/namespace.d.ts +0 -18
  143. package/out-tsc/vitest/src/namespace.d.ts.map +0 -1
  144. package/out-tsc/vitest/src/render/ErrorBoundary.d.ts +0 -17
  145. package/out-tsc/vitest/src/render/ErrorBoundary.d.ts.map +0 -1
  146. package/out-tsc/vitest/src/render/TestComponentOverlay.d.ts +0 -3
  147. package/out-tsc/vitest/src/render/TestComponentOverlay.d.ts.map +0 -1
  148. package/out-tsc/vitest/src/render/cleanup.d.ts +0 -2
  149. package/out-tsc/vitest/src/render/cleanup.d.ts.map +0 -1
  150. package/out-tsc/vitest/src/render/index.d.ts +0 -6
  151. package/out-tsc/vitest/src/render/index.d.ts.map +0 -1
  152. package/out-tsc/vitest/src/render/setup.d.ts +0 -2
  153. package/out-tsc/vitest/src/render/setup.d.ts.map +0 -1
  154. package/out-tsc/vitest/src/render/types.d.ts +0 -12
  155. package/out-tsc/vitest/src/render/types.d.ts.map +0 -1
  156. package/out-tsc/vitest/src/runner/errors.d.ts +0 -11
  157. package/out-tsc/vitest/src/runner/errors.d.ts.map +0 -1
  158. package/out-tsc/vitest/src/runner/factory.d.ts +0 -3
  159. package/out-tsc/vitest/src/runner/factory.d.ts.map +0 -1
  160. package/out-tsc/vitest/src/runner/hooks.d.ts +0 -4
  161. package/out-tsc/vitest/src/runner/hooks.d.ts.map +0 -1
  162. package/out-tsc/vitest/src/runner/index.d.ts +0 -4
  163. package/out-tsc/vitest/src/runner/index.d.ts.map +0 -1
  164. package/out-tsc/vitest/src/runner/runSuite.d.ts +0 -4
  165. package/out-tsc/vitest/src/runner/runSuite.d.ts.map +0 -1
  166. package/out-tsc/vitest/src/runner/types.d.ts +0 -13
  167. package/out-tsc/vitest/src/runner/types.d.ts.map +0 -1
  168. package/out-tsc/vitest/src/screen/index.d.ts +0 -8
  169. package/out-tsc/vitest/src/screen/index.d.ts.map +0 -1
  170. package/out-tsc/vitest/src/spy/index.d.ts +0 -2
  171. package/out-tsc/vitest/src/spy/index.d.ts.map +0 -1
  172. package/out-tsc/vitest/src/symbolicate.d.ts +0 -3
  173. package/out-tsc/vitest/src/symbolicate.d.ts.map +0 -1
  174. package/out-tsc/vitest/src/ui/ReadyScreen.d.ts +0 -2
  175. package/out-tsc/vitest/src/ui/ReadyScreen.d.ts.map +0 -1
  176. package/out-tsc/vitest/src/ui/WrongEnvironmentScreen.d.ts +0 -2
  177. package/out-tsc/vitest/src/ui/WrongEnvironmentScreen.d.ts.map +0 -1
  178. package/out-tsc/vitest/src/ui/index.d.ts +0 -2
  179. package/out-tsc/vitest/src/ui/index.d.ts.map +0 -1
  180. package/out-tsc/vitest/src/ui/state.d.ts +0 -20
  181. package/out-tsc/vitest/src/ui/state.d.ts.map +0 -1
  182. package/out-tsc/vitest/src/userEvent/index.d.ts +0 -6
  183. package/out-tsc/vitest/src/userEvent/index.d.ts.map +0 -1
  184. package/out-tsc/vitest/src/utils/dev-server.d.ts +0 -2
  185. package/out-tsc/vitest/src/utils/dev-server.d.ts.map +0 -1
  186. package/out-tsc/vitest/src/utils/emitter.d.ts +0 -16
  187. package/out-tsc/vitest/src/utils/emitter.d.ts.map +0 -1
  188. package/out-tsc/vitest/src/waitFor.d.ts +0 -21
  189. package/out-tsc/vitest/src/waitFor.d.ts.map +0 -1
  190. package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +0 -1
  191. package/out-tsc/vitest/vite.config.d.ts +0 -3
  192. package/out-tsc/vitest/vite.config.d.ts.map +0 -1
@@ -0,0 +1,39 @@
1
+ type TestFn = () => void | Promise<void>;
2
+ export type TestStatus = 'active' | 'skipped' | 'todo';
3
+ export interface TestCase {
4
+ name: string;
5
+ fn: TestFn;
6
+ status: TestStatus;
7
+ }
8
+ export interface TestSuite {
9
+ name: string;
10
+ tests: TestCase[];
11
+ suites: TestSuite[];
12
+ beforeAll: TestFn[];
13
+ afterAll: TestFn[];
14
+ beforeEach: TestFn[];
15
+ afterEach: TestFn[];
16
+ status?: TestStatus;
17
+ _hasFocused?: boolean;
18
+ }
19
+ export declare const describe: ((name: string, fn: () => void) => void) & {
20
+ skip: (name: string, fn: () => void) => void;
21
+ only: (name: string, fn: () => void) => void;
22
+ };
23
+ export declare const test: ((name: string, fn: TestFn) => void) & {
24
+ skip: (name: string, fn: TestFn) => void;
25
+ only: (name: string, fn: TestFn) => void;
26
+ todo: (name: string) => void;
27
+ };
28
+ export declare const it: ((name: string, fn: TestFn) => void) & {
29
+ skip: (name: string, fn: TestFn) => void;
30
+ only: (name: string, fn: TestFn) => void;
31
+ todo: (name: string) => void;
32
+ };
33
+ export declare function beforeAll(fn: TestFn): void;
34
+ export declare function afterAll(fn: TestFn): void;
35
+ export declare function beforeEach(fn: TestFn): void;
36
+ export declare function afterEach(fn: TestFn): void;
37
+ export declare const collectTests: (fn: () => void) => TestSuite;
38
+ export {};
39
+ //# sourceMappingURL=collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,KAAK,MAAM,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAEvD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAwED,eAAO,MAAM,QAAQ,UACZ,MAAM,MAAM,MAAM,IAAI;iBA+Bd,MAAM,MAAM,MAAM,IAAI;iBAkBtB,MAAM,MAAM,MAAM,IAAI;CA0CtC,CAAC;AAcF,eAAO,MAAM,IAAI,UACR,MAAM,MAAM,MAAM;iBAYV,MAAM,MAAM,MAAM;iBAOlB,MAAM,MAAM,MAAM;iBAqBlB,MAAM;CAQtB,CAAC;AAEF,eAAO,MAAM,EAAE,UAlDN,MAAM,MAAM,MAAM;iBAYV,MAAM,MAAM,MAAM;iBAOlB,MAAM,MAAM,MAAM;iBAqBlB,MAAM;CAUD,CAAC;AAEvB,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAMnC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,QAMlC;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,QAMpC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAMnC;AAWD,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,IAAI,KAAG,SAK7C,CAAC"}
@@ -0,0 +1,224 @@
1
+ const clearState = () => {
2
+ const rootSuite = createSuite('root');
3
+ globalThis.__INTERNAL_COLLECTION__ = {
4
+ rootSuite,
5
+ currentSuite: rootSuite,
6
+ hasFocusedTests: false,
7
+ };
8
+ };
9
+ const getCurrentSuite = () => globalThis.__INTERNAL_COLLECTION__?.currentSuite ??
10
+ null;
11
+ const getRootSuite = () => {
12
+ const internalCollection = globalThis
13
+ .__INTERNAL_COLLECTION__;
14
+ if (!internalCollection) {
15
+ throw new Error('Internal collection not initialized');
16
+ }
17
+ return internalCollection.rootSuite;
18
+ };
19
+ const setCurrentSuite = (suite) => {
20
+ const internalCollection = globalThis
21
+ .__INTERNAL_COLLECTION__;
22
+ if (internalCollection) {
23
+ internalCollection.currentSuite = suite;
24
+ }
25
+ };
26
+ const getHasFocusedTests = () => {
27
+ const internalCollection = globalThis
28
+ .__INTERNAL_COLLECTION__;
29
+ return internalCollection?.hasFocusedTests || false;
30
+ };
31
+ const setHasFocusedTests = (value) => {
32
+ const internalCollection = globalThis
33
+ .__INTERNAL_COLLECTION__;
34
+ if (internalCollection) {
35
+ internalCollection.hasFocusedTests = value;
36
+ }
37
+ };
38
+ function createSuite(name, status = 'active') {
39
+ return {
40
+ name,
41
+ tests: [],
42
+ suites: [],
43
+ beforeAll: [],
44
+ afterAll: [],
45
+ beforeEach: [],
46
+ afterEach: [],
47
+ status,
48
+ };
49
+ }
50
+ export const describe = Object.assign((name, fn) => {
51
+ const suite = createSuite(name);
52
+ const previousSuite = getCurrentSuite();
53
+ // Only mark suites as skipped when ran after .only is called
54
+ suite.status =
55
+ getHasFocusedTests() && previousSuite !== getRootSuite()
56
+ ? 'skipped'
57
+ : 'active';
58
+ setCurrentSuite(suite);
59
+ try {
60
+ fn();
61
+ }
62
+ finally {
63
+ setCurrentSuite(previousSuite);
64
+ }
65
+ // If this suite has focused tests/suites, propagate up to parent
66
+ if (suite._hasFocused && previousSuite) {
67
+ previousSuite._hasFocused = true;
68
+ suite.status = 'active';
69
+ }
70
+ // Add the suite to its parent
71
+ if (previousSuite) {
72
+ previousSuite.suites.push(suite);
73
+ }
74
+ else {
75
+ getRootSuite().suites.push(suite);
76
+ }
77
+ }, {
78
+ skip: (name, fn) => {
79
+ const suite = createSuite(name, 'skipped');
80
+ const previousSuite = getCurrentSuite();
81
+ setCurrentSuite(suite);
82
+ try {
83
+ fn();
84
+ }
85
+ finally {
86
+ setCurrentSuite(previousSuite);
87
+ }
88
+ // Add the suite to its parent
89
+ if (previousSuite) {
90
+ previousSuite.suites.push(suite);
91
+ }
92
+ else {
93
+ getRootSuite().suites.push(suite);
94
+ }
95
+ },
96
+ only: (name, fn) => {
97
+ // Mark that we have focused tests in the test run
98
+ setHasFocusedTests(true);
99
+ const suite = createSuite(name, 'active');
100
+ suite._hasFocused = true;
101
+ const previousSuite = getCurrentSuite();
102
+ // Mark that parent suite has a focused child and should remain active
103
+ if (previousSuite) {
104
+ previousSuite._hasFocused = true;
105
+ // Skip sibling suites
106
+ for (const s of previousSuite.suites) {
107
+ s.status = 'skipped';
108
+ }
109
+ previousSuite.status = 'active';
110
+ }
111
+ else {
112
+ // If this is at the root level, mark all existing suites as skipped
113
+ const rootSuite = getRootSuite();
114
+ for (const s of rootSuite.suites) {
115
+ s.status = 'skipped';
116
+ }
117
+ }
118
+ setCurrentSuite(suite);
119
+ try {
120
+ fn();
121
+ }
122
+ finally {
123
+ setCurrentSuite(previousSuite);
124
+ }
125
+ // Add the suite to its parent
126
+ if (previousSuite) {
127
+ previousSuite.suites.push(suite);
128
+ }
129
+ else {
130
+ getRootSuite().suites.push(suite);
131
+ }
132
+ },
133
+ });
134
+ function createTest(name, fn, status = 'active') {
135
+ return {
136
+ name,
137
+ fn,
138
+ status,
139
+ };
140
+ }
141
+ export const test = Object.assign((name, fn) => {
142
+ const currentSuite = getCurrentSuite();
143
+ if (!currentSuite) {
144
+ throw new Error('test() must be called within a describe() block');
145
+ }
146
+ // If running tests directly, don't apply the hasFocusedTests check
147
+ // Tests only get skipped by `.only` in the same test suite
148
+ const status = currentSuite._hasFocused ? 'skipped' : 'active';
149
+ currentSuite.tests.push(createTest(name, fn, status));
150
+ }, {
151
+ skip: (name, fn) => {
152
+ const currentSuite = getCurrentSuite();
153
+ if (!currentSuite) {
154
+ throw new Error('test.skip() must be called within a describe() block');
155
+ }
156
+ currentSuite.tests.push(createTest(name, fn, 'skipped'));
157
+ },
158
+ only: (name, fn) => {
159
+ const currentSuite = getCurrentSuite();
160
+ if (!currentSuite) {
161
+ throw new Error('test.only() must be called within a describe() block');
162
+ }
163
+ // Mark the suite as having focused tests
164
+ currentSuite._hasFocused = true;
165
+ // Mark all existing tests in this suite as skipped
166
+ for (const test of currentSuite.tests) {
167
+ test.status = 'skipped';
168
+ }
169
+ // Add the new focused test
170
+ const newTest = createTest(name, fn, 'active');
171
+ currentSuite.tests.push(newTest);
172
+ // All subsequent tests in this suite will be skipped
173
+ // This happens automatically because of the _hasFocused flag
174
+ },
175
+ todo: (name) => {
176
+ const currentSuite = getCurrentSuite();
177
+ if (!currentSuite) {
178
+ throw new Error('test.todo() must be called within a describe() block');
179
+ }
180
+ currentSuite.tests.push(createTest(name, () => { }, 'todo'));
181
+ },
182
+ });
183
+ export const it = test;
184
+ export function beforeAll(fn) {
185
+ const currentSuite = getCurrentSuite();
186
+ if (!currentSuite) {
187
+ throw new Error('beforeAll() must be called within a describe() block');
188
+ }
189
+ currentSuite.beforeAll.push(fn);
190
+ }
191
+ export function afterAll(fn) {
192
+ const currentSuite = getCurrentSuite();
193
+ if (!currentSuite) {
194
+ throw new Error('afterAll() must be called within a describe() block');
195
+ }
196
+ currentSuite.afterAll.push(fn);
197
+ }
198
+ export function beforeEach(fn) {
199
+ const currentSuite = getCurrentSuite();
200
+ if (!currentSuite) {
201
+ throw new Error('beforeEach() must be called within a describe() block');
202
+ }
203
+ currentSuite.beforeEach.push(fn);
204
+ }
205
+ export function afterEach(fn) {
206
+ const currentSuite = getCurrentSuite();
207
+ if (!currentSuite) {
208
+ throw new Error('afterEach() must be called within a describe() block');
209
+ }
210
+ currentSuite.afterEach.push(fn);
211
+ }
212
+ const typedGlobal = global;
213
+ typedGlobal.describe = describe;
214
+ typedGlobal.test = test;
215
+ typedGlobal.it = it;
216
+ typedGlobal.beforeAll = beforeAll;
217
+ typedGlobal.afterAll = afterAll;
218
+ typedGlobal.beforeEach = beforeEach;
219
+ typedGlobal.afterEach = afterEach;
220
+ export const collectTests = (fn) => {
221
+ clearState();
222
+ fn();
223
+ return getRootSuite();
224
+ };
@@ -0,0 +1,6 @@
1
+ import { ComponentType } from 'react';
2
+ declare global {
3
+ var RN_HARNESS: boolean;
4
+ }
5
+ export declare const getEntryComponent: (Component: ComponentType) => any;
6
+ //# sourceMappingURL=getEntryComponent.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,6 @@
1
+ export const getEntryComponent = (Component) => {
2
+ if ('RN_HARNESS' in global) {
3
+ return require('./ui/UI').default;
4
+ }
5
+ return Component;
6
+ };
@@ -0,0 +1,3 @@
1
+ export declare const fetchModule: (fileName: string) => Promise<string>;
2
+ export declare const executeModule: (moduleJs: string) => void;
3
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAgBA,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 ADDED
@@ -0,0 +1,26 @@
1
+ import { Platform } from 'react-native';
2
+ import { URL, URLSearchParams } from 'react-native-url-polyfill';
3
+ const METRO_URL = 'http://localhost:8081';
4
+ const getModuleUrl = (fileName) => {
5
+ const url = new URL(METRO_URL);
6
+ const bundleName = fileName.split('.').slice(0, -1).join('.') + '.bundle';
7
+ url.search = new URLSearchParams({
8
+ modulesOnly: 'true',
9
+ platform: Platform.OS,
10
+ }).toString();
11
+ url.pathname = `/${bundleName}`;
12
+ return url.toString();
13
+ };
14
+ export const fetchModule = async (fileName) => {
15
+ const url = getModuleUrl(fileName);
16
+ const response = await fetch(url);
17
+ return response.text();
18
+ };
19
+ export const executeModule = (moduleJs) => {
20
+ const __rMatch = moduleJs.match(/__r\((\d+)\)/);
21
+ const __rParam = __rMatch[1];
22
+ // eslint-disable-next-line no-eval
23
+ eval(moduleJs);
24
+ // @ts-ignore - __r is injected by Metro bundler
25
+ __r(Number(__rParam));
26
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=module.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.web.d.ts","sourceRoot":"","sources":["../src/module.web.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
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
+ // };
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@react-native-harness/runtime",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "./package.json": "./package.json",
10
+ ".": {
11
+ "development": "./src/index.ts",
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "peerDependencies": {
18
+ "react": "~18.3.1",
19
+ "react-native": "~0.76.3"
20
+ },
21
+ "dependencies": {
22
+ "@react-native-harness/bridge": "workspace:*",
23
+ "chai": "^5.2.0",
24
+ "chai-as-promised": "^8.0.1",
25
+ "react-native-url-polyfill": "^2.0.0",
26
+ "sinon": "^21.0.0",
27
+ "sinon-chai": "^4.0.0",
28
+ "zustand": "^5.0.5"
29
+ },
30
+ "devDependencies": {
31
+ "@react-native-harness/interaction-engine": "workspace:*",
32
+ "@types/chai": "^5.2.2",
33
+ "@types/chai-as-promised": "^8.0.2",
34
+ "@types/sinon": "^17.0.4",
35
+ "@types/sinon-chai": "^4.0.0"
36
+ }
37
+ }
@@ -0,0 +1,3 @@
1
+ import { BridgeClient } from '@react-native-harness/bridge/client';
2
+ export declare const getClient: () => BridgeClient;
3
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,8 @@
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
+ };
@@ -1,5 +1,21 @@
1
- import type { CollectionResult } from '@react-native-harness/bridge';
2
- import type { TestFn } from './types.js';
1
+ type TestFn = () => void | Promise<void>;
2
+ export type TestStatus = 'active' | 'skipped' | 'todo';
3
+ export interface TestCase {
4
+ name: string;
5
+ fn: TestFn;
6
+ status: TestStatus;
7
+ }
8
+ export interface TestSuite {
9
+ name: string;
10
+ tests: TestCase[];
11
+ suites: TestSuite[];
12
+ beforeAll: TestFn[];
13
+ afterAll: TestFn[];
14
+ beforeEach: TestFn[];
15
+ afterEach: TestFn[];
16
+ status?: TestStatus;
17
+ _hasFocused?: boolean;
18
+ }
3
19
  export declare const describe: ((name: string, fn: () => void) => void) & {
4
20
  skip: (name: string, fn: () => void) => void;
5
21
  only: (name: string, fn: () => void) => void;
@@ -18,5 +34,6 @@ export declare function beforeAll(fn: TestFn): void;
18
34
  export declare function afterAll(fn: TestFn): void;
19
35
  export declare function beforeEach(fn: TestFn): void;
20
36
  export declare function afterEach(fn: TestFn): void;
21
- export declare const collectTests: (fn: () => void | Promise<void>) => Promise<CollectionResult>;
22
- //# sourceMappingURL=functions.d.ts.map
37
+ export declare const collectTests: (fn: () => void) => TestSuite;
38
+ export {};
39
+ //# sourceMappingURL=describe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/rntl/describe.ts"],"names":[],"mappings":"AAAA,KAAK,MAAM,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAEvD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAwED,eAAO,MAAM,QAAQ,UACZ,MAAM,MAAM,MAAM,IAAI;iBA+Bd,MAAM,MAAM,MAAM,IAAI;iBAkBtB,MAAM,MAAM,MAAM,IAAI;CA0CtC,CAAC;AAcF,eAAO,MAAM,IAAI,UACR,MAAM,MAAM,MAAM;iBAYV,MAAM,MAAM,MAAM;iBAOlB,MAAM,MAAM,MAAM;iBAqBlB,MAAM;CAQtB,CAAC;AAEF,eAAO,MAAM,EAAE,UAlDN,MAAM,MAAM,MAAM;iBAYV,MAAM,MAAM,MAAM;iBAOlB,MAAM,MAAM,MAAM;iBAqBlB,MAAM;CAUD,CAAC;AAEvB,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAMnC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,QAMlC;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,QAMpC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAMnC;AAED,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,IAAI,KAAG,SAK7C,CAAC"}
@@ -0,0 +1,216 @@
1
+ const clearState = () => {
2
+ const rootSuite = createSuite('root');
3
+ globalThis.__INTERNAL_COLLECTION__ = {
4
+ rootSuite,
5
+ currentSuite: rootSuite,
6
+ hasFocusedTests: false,
7
+ };
8
+ };
9
+ const getCurrentSuite = () => globalThis.__INTERNAL_COLLECTION__?.currentSuite ??
10
+ null;
11
+ const getRootSuite = () => {
12
+ const internalCollection = globalThis
13
+ .__INTERNAL_COLLECTION__;
14
+ if (!internalCollection) {
15
+ throw new Error('Internal collection not initialized');
16
+ }
17
+ return internalCollection.rootSuite;
18
+ };
19
+ const setCurrentSuite = (suite) => {
20
+ const internalCollection = globalThis
21
+ .__INTERNAL_COLLECTION__;
22
+ if (internalCollection) {
23
+ internalCollection.currentSuite = suite;
24
+ }
25
+ };
26
+ const getHasFocusedTests = () => {
27
+ const internalCollection = globalThis
28
+ .__INTERNAL_COLLECTION__;
29
+ return internalCollection?.hasFocusedTests || false;
30
+ };
31
+ const setHasFocusedTests = (value) => {
32
+ const internalCollection = globalThis
33
+ .__INTERNAL_COLLECTION__;
34
+ if (internalCollection) {
35
+ internalCollection.hasFocusedTests = value;
36
+ }
37
+ };
38
+ function createSuite(name, status = 'active') {
39
+ return {
40
+ name,
41
+ tests: [],
42
+ suites: [],
43
+ beforeAll: [],
44
+ afterAll: [],
45
+ beforeEach: [],
46
+ afterEach: [],
47
+ status,
48
+ };
49
+ }
50
+ export const describe = Object.assign((name, fn) => {
51
+ const suite = createSuite(name);
52
+ const previousSuite = getCurrentSuite();
53
+ // Only mark suites as skipped when ran after .only is called
54
+ suite.status =
55
+ getHasFocusedTests() && previousSuite !== getRootSuite()
56
+ ? 'skipped'
57
+ : 'active';
58
+ setCurrentSuite(suite);
59
+ try {
60
+ fn();
61
+ }
62
+ finally {
63
+ setCurrentSuite(previousSuite);
64
+ }
65
+ // If this suite has focused tests/suites, propagate up to parent
66
+ if (suite._hasFocused && previousSuite) {
67
+ previousSuite._hasFocused = true;
68
+ suite.status = 'active';
69
+ }
70
+ // Add the suite to its parent
71
+ if (previousSuite) {
72
+ previousSuite.suites.push(suite);
73
+ }
74
+ else {
75
+ getRootSuite().suites.push(suite);
76
+ }
77
+ }, {
78
+ skip: (name, fn) => {
79
+ const suite = createSuite(name, 'skipped');
80
+ const previousSuite = getCurrentSuite();
81
+ setCurrentSuite(suite);
82
+ try {
83
+ fn();
84
+ }
85
+ finally {
86
+ setCurrentSuite(previousSuite);
87
+ }
88
+ // Add the suite to its parent
89
+ if (previousSuite) {
90
+ previousSuite.suites.push(suite);
91
+ }
92
+ else {
93
+ getRootSuite().suites.push(suite);
94
+ }
95
+ },
96
+ only: (name, fn) => {
97
+ // Mark that we have focused tests in the test run
98
+ setHasFocusedTests(true);
99
+ const suite = createSuite(name, 'active');
100
+ suite._hasFocused = true;
101
+ const previousSuite = getCurrentSuite();
102
+ // Mark that parent suite has a focused child and should remain active
103
+ if (previousSuite) {
104
+ previousSuite._hasFocused = true;
105
+ // Skip sibling suites
106
+ for (const s of previousSuite.suites) {
107
+ s.status = 'skipped';
108
+ }
109
+ previousSuite.status = 'active';
110
+ }
111
+ else {
112
+ // If this is at the root level, mark all existing suites as skipped
113
+ const rootSuite = getRootSuite();
114
+ for (const s of rootSuite.suites) {
115
+ s.status = 'skipped';
116
+ }
117
+ }
118
+ setCurrentSuite(suite);
119
+ try {
120
+ fn();
121
+ }
122
+ finally {
123
+ setCurrentSuite(previousSuite);
124
+ }
125
+ // Add the suite to its parent
126
+ if (previousSuite) {
127
+ previousSuite.suites.push(suite);
128
+ }
129
+ else {
130
+ getRootSuite().suites.push(suite);
131
+ }
132
+ },
133
+ });
134
+ function createTest(name, fn, status = 'active') {
135
+ return {
136
+ name,
137
+ fn,
138
+ status,
139
+ };
140
+ }
141
+ export const test = Object.assign((name, fn) => {
142
+ const currentSuite = getCurrentSuite();
143
+ if (!currentSuite) {
144
+ throw new Error('test() must be called within a describe() block');
145
+ }
146
+ // If running tests directly, don't apply the hasFocusedTests check
147
+ // Tests only get skipped by `.only` in the same test suite
148
+ const status = currentSuite._hasFocused ? 'skipped' : 'active';
149
+ currentSuite.tests.push(createTest(name, fn, status));
150
+ }, {
151
+ skip: (name, fn) => {
152
+ const currentSuite = getCurrentSuite();
153
+ if (!currentSuite) {
154
+ throw new Error('test.skip() must be called within a describe() block');
155
+ }
156
+ currentSuite.tests.push(createTest(name, fn, 'skipped'));
157
+ },
158
+ only: (name, fn) => {
159
+ const currentSuite = getCurrentSuite();
160
+ if (!currentSuite) {
161
+ throw new Error('test.only() must be called within a describe() block');
162
+ }
163
+ // Mark the suite as having focused tests
164
+ currentSuite._hasFocused = true;
165
+ // Mark all existing tests in this suite as skipped
166
+ for (const test of currentSuite.tests) {
167
+ test.status = 'skipped';
168
+ }
169
+ // Add the new focused test
170
+ const newTest = createTest(name, fn, 'active');
171
+ currentSuite.tests.push(newTest);
172
+ // All subsequent tests in this suite will be skipped
173
+ // This happens automatically because of the _hasFocused flag
174
+ },
175
+ todo: (name) => {
176
+ const currentSuite = getCurrentSuite();
177
+ if (!currentSuite) {
178
+ throw new Error('test.todo() must be called within a describe() block');
179
+ }
180
+ currentSuite.tests.push(createTest(name, () => { }, 'todo'));
181
+ },
182
+ });
183
+ export const it = test;
184
+ export function beforeAll(fn) {
185
+ const currentSuite = getCurrentSuite();
186
+ if (!currentSuite) {
187
+ throw new Error('beforeAll() must be called within a describe() block');
188
+ }
189
+ currentSuite.beforeAll.push(fn);
190
+ }
191
+ export function afterAll(fn) {
192
+ const currentSuite = getCurrentSuite();
193
+ if (!currentSuite) {
194
+ throw new Error('afterAll() must be called within a describe() block');
195
+ }
196
+ currentSuite.afterAll.push(fn);
197
+ }
198
+ export function beforeEach(fn) {
199
+ const currentSuite = getCurrentSuite();
200
+ if (!currentSuite) {
201
+ throw new Error('beforeEach() must be called within a describe() block');
202
+ }
203
+ currentSuite.beforeEach.push(fn);
204
+ }
205
+ export function afterEach(fn) {
206
+ const currentSuite = getCurrentSuite();
207
+ if (!currentSuite) {
208
+ throw new Error('afterEach() must be called within a describe() block');
209
+ }
210
+ currentSuite.afterEach.push(fn);
211
+ }
212
+ export const collectTests = (fn) => {
213
+ clearState();
214
+ fn();
215
+ return getRootSuite();
216
+ };
@@ -0,0 +1,11 @@
1
+ export { expect } from 'chai';
2
+ declare global {
3
+ namespace Chai {
4
+ interface Assertion {
5
+ toBeDisplayed(): Promise<void>;
6
+ toBeDisabled(): Promise<void>;
7
+ toBeEnabled(): Promise<void>;
8
+ }
9
+ }
10
+ }
11
+ //# sourceMappingURL=expect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/rntl/expect.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAsC9B,OAAO,CAAC,MAAM,CAAC;IAGb,UAAU,IAAI,CAAC;QACb,UAAU,SAAS;YACjB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;YAC9B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;SAC9B;KACF;CACF"}