@react-native-harness/runtime 1.0.0-alpha.9 → 1.0.0-canary.1761729829908

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/README.md +23 -4
  2. package/assets/moduleSystem.flow.js +23 -3
  3. package/dist/bundler/bundle.d.ts.map +1 -1
  4. package/dist/bundler/bundle.js +1 -2
  5. package/dist/bundler/evaluate.d.ts.map +1 -1
  6. package/dist/bundler/evaluate.js +7 -7
  7. package/dist/bundler/factory.d.ts +3 -0
  8. package/dist/bundler/factory.d.ts.map +1 -0
  9. package/dist/bundler/factory.js +36 -0
  10. package/dist/bundler/index.d.ts +2 -1
  11. package/dist/bundler/index.d.ts.map +1 -1
  12. package/dist/bundler/index.js +1 -1
  13. package/dist/bundler/types.d.ts +7 -0
  14. package/dist/bundler/types.d.ts.map +1 -0
  15. package/dist/bundler/types.js +1 -0
  16. package/dist/client/factory.d.ts.map +1 -1
  17. package/dist/client/factory.js +33 -12
  18. package/dist/client/getDeviceDescriptor.d.ts +1 -1
  19. package/dist/client/getDeviceDescriptor.d.ts.map +1 -1
  20. package/dist/client/getDeviceDescriptor.js +18 -6
  21. package/dist/client/setup-files.d.ts +12 -0
  22. package/dist/client/setup-files.d.ts.map +1 -0
  23. package/dist/client/setup-files.js +60 -0
  24. package/dist/collector/functions.d.ts +1 -1
  25. package/dist/collector/functions.d.ts.map +1 -1
  26. package/dist/collector/functions.js +10 -2
  27. package/dist/collector/types.d.ts +1 -1
  28. package/dist/collector/types.d.ts.map +1 -1
  29. package/dist/constants.d.ts +0 -1
  30. package/dist/constants.d.ts.map +1 -1
  31. package/dist/constants.js +0 -1
  32. package/dist/entry-point.d.ts +2 -0
  33. package/dist/entry-point.d.ts.map +1 -0
  34. package/dist/entry-point.js +4 -0
  35. package/dist/expect/index.d.ts.map +1 -1
  36. package/dist/expect/index.js +2 -0
  37. package/dist/expect/setup.js +2 -0
  38. package/dist/filtering/index.d.ts +2 -0
  39. package/dist/filtering/index.d.ts.map +1 -0
  40. package/dist/filtering/index.js +1 -0
  41. package/dist/filtering/testNameFilter.d.ts +12 -0
  42. package/dist/filtering/testNameFilter.d.ts.map +1 -0
  43. package/dist/filtering/testNameFilter.js +56 -0
  44. package/dist/globals.d.ts +5 -2
  45. package/dist/globals.d.ts.map +1 -1
  46. package/dist/globals.js +7 -1
  47. package/dist/index.d.ts +3 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +3 -0
  50. package/dist/initialize.js +7 -0
  51. package/dist/jest-mock.d.ts +2 -0
  52. package/dist/jest-mock.d.ts.map +1 -0
  53. package/dist/jest-mock.js +25 -0
  54. package/dist/mocker/index.d.ts +1 -1
  55. package/dist/mocker/index.d.ts.map +1 -1
  56. package/dist/mocker/index.js +1 -1
  57. package/dist/mocker/registry.d.ts +2 -2
  58. package/dist/mocker/registry.d.ts.map +1 -1
  59. package/dist/mocker/registry.js +10 -4
  60. package/dist/namespace.d.ts +18 -0
  61. package/dist/namespace.d.ts.map +1 -0
  62. package/dist/namespace.js +19 -0
  63. package/dist/render/ErrorBoundary.d.ts +17 -0
  64. package/dist/render/ErrorBoundary.d.ts.map +1 -0
  65. package/dist/render/ErrorBoundary.js +73 -0
  66. package/dist/render/TestComponentOverlay.d.ts +3 -0
  67. package/dist/render/TestComponentOverlay.d.ts.map +1 -0
  68. package/dist/render/TestComponentOverlay.js +36 -0
  69. package/dist/render/cleanup.d.ts +2 -0
  70. package/dist/render/cleanup.d.ts.map +1 -0
  71. package/dist/render/cleanup.js +6 -0
  72. package/dist/render/index.d.ts +6 -0
  73. package/dist/render/index.d.ts.map +1 -0
  74. package/dist/render/index.js +66 -0
  75. package/dist/render/setup.d.ts +2 -0
  76. package/dist/render/setup.d.ts.map +1 -0
  77. package/dist/render/setup.js +7 -0
  78. package/dist/render/types.d.ts +12 -0
  79. package/dist/render/types.d.ts.map +1 -0
  80. package/dist/render/types.js +1 -0
  81. package/dist/runner/factory.d.ts.map +1 -1
  82. package/dist/runner/factory.js +6 -1
  83. package/dist/runner/runSuite.d.ts.map +1 -1
  84. package/dist/runner/runSuite.js +37 -0
  85. package/dist/symbolicate.d.ts.map +1 -1
  86. package/dist/symbolicate.js +5 -4
  87. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  88. package/dist/ui/ReadyScreen.d.ts.map +1 -1
  89. package/dist/ui/ReadyScreen.js +3 -10
  90. package/dist/ui/WrongEnvironmentScreen.d.ts.map +1 -1
  91. package/dist/ui/WrongEnvironmentScreen.js +2 -10
  92. package/dist/ui/state.d.ts +13 -0
  93. package/dist/ui/state.d.ts.map +1 -1
  94. package/dist/ui/state.js +22 -0
  95. package/dist/utils/emitter.d.ts.map +1 -1
  96. package/dist/waitFor.d.ts +21 -0
  97. package/dist/waitFor.d.ts.map +1 -0
  98. package/dist/waitFor.js +137 -0
  99. package/eslint.config.mjs +1 -7
  100. package/out-tsc/vitest/src/__tests__/collector.test.d.ts +2 -0
  101. package/out-tsc/vitest/src/__tests__/collector.test.d.ts.map +1 -0
  102. package/out-tsc/vitest/src/__tests__/error-handling.test.d.ts +2 -0
  103. package/out-tsc/vitest/src/__tests__/error-handling.test.d.ts.map +1 -0
  104. package/out-tsc/vitest/src/__tests__/expect.test.d.ts +2 -0
  105. package/out-tsc/vitest/src/__tests__/expect.test.d.ts.map +1 -0
  106. package/out-tsc/vitest/src/__tests__/spy.test.d.ts +2 -0
  107. package/out-tsc/vitest/src/__tests__/spy.test.d.ts.map +1 -0
  108. package/out-tsc/vitest/src/bundler/bundle.d.ts +2 -0
  109. package/out-tsc/vitest/src/bundler/bundle.d.ts.map +1 -0
  110. package/out-tsc/vitest/src/bundler/errors.d.ts +15 -0
  111. package/out-tsc/vitest/src/bundler/errors.d.ts.map +1 -0
  112. package/out-tsc/vitest/src/bundler/evaluate.d.ts +2 -0
  113. package/out-tsc/vitest/src/bundler/evaluate.d.ts.map +1 -0
  114. package/out-tsc/vitest/src/bundler/factory.d.ts +3 -0
  115. package/out-tsc/vitest/src/bundler/factory.d.ts.map +1 -0
  116. package/out-tsc/vitest/src/bundler/index.d.ts +4 -0
  117. package/out-tsc/vitest/src/bundler/index.d.ts.map +1 -0
  118. package/out-tsc/vitest/src/bundler/types.d.ts +7 -0
  119. package/out-tsc/vitest/src/bundler/types.d.ts.map +1 -0
  120. package/out-tsc/vitest/src/client/factory.d.ts +2 -0
  121. package/out-tsc/vitest/src/client/factory.d.ts.map +1 -0
  122. package/out-tsc/vitest/src/client/getDeviceDescriptor.d.ts +8 -0
  123. package/out-tsc/vitest/src/client/getDeviceDescriptor.d.ts.map +1 -0
  124. package/out-tsc/vitest/src/client/getWSServer.d.ts +2 -0
  125. package/out-tsc/vitest/src/client/getWSServer.d.ts.map +1 -0
  126. package/out-tsc/vitest/src/client/index.d.ts +2 -0
  127. package/out-tsc/vitest/src/client/index.d.ts.map +1 -0
  128. package/out-tsc/vitest/src/collector/errors.d.ts +8 -0
  129. package/out-tsc/vitest/src/collector/errors.d.ts.map +1 -0
  130. package/out-tsc/vitest/src/collector/factory.d.ts +3 -0
  131. package/out-tsc/vitest/src/collector/factory.d.ts.map +1 -0
  132. package/out-tsc/vitest/src/collector/functions.d.ts +22 -0
  133. package/out-tsc/vitest/src/collector/functions.d.ts.map +1 -0
  134. package/out-tsc/vitest/src/collector/index.d.ts +5 -0
  135. package/out-tsc/vitest/src/collector/index.d.ts.map +1 -0
  136. package/out-tsc/vitest/src/collector/types.d.ts +10 -0
  137. package/out-tsc/vitest/src/collector/types.d.ts.map +1 -0
  138. package/out-tsc/vitest/src/collector/validation.d.ts +4 -0
  139. package/out-tsc/vitest/src/collector/validation.d.ts.map +1 -0
  140. package/out-tsc/vitest/src/constants.d.ts +3 -0
  141. package/out-tsc/vitest/src/constants.d.ts.map +1 -0
  142. package/out-tsc/vitest/src/entry-point.d.ts +2 -0
  143. package/out-tsc/vitest/src/entry-point.d.ts.map +1 -0
  144. package/out-tsc/vitest/src/errors.d.ts +6 -0
  145. package/out-tsc/vitest/src/errors.d.ts.map +1 -0
  146. package/out-tsc/vitest/src/expect/index.d.ts +9 -0
  147. package/out-tsc/vitest/src/expect/index.d.ts.map +1 -0
  148. package/out-tsc/vitest/src/expect/setup.d.ts +2 -0
  149. package/out-tsc/vitest/src/expect/setup.d.ts.map +1 -0
  150. package/out-tsc/vitest/src/filtering/index.d.ts +2 -0
  151. package/out-tsc/vitest/src/filtering/index.d.ts.map +1 -0
  152. package/out-tsc/vitest/src/filtering/testNameFilter.d.ts +12 -0
  153. package/out-tsc/vitest/src/filtering/testNameFilter.d.ts.map +1 -0
  154. package/out-tsc/vitest/src/globals.d.ts +8 -0
  155. package/out-tsc/vitest/src/globals.d.ts.map +1 -0
  156. package/out-tsc/vitest/src/index.d.ts +9 -0
  157. package/out-tsc/vitest/src/index.d.ts.map +1 -0
  158. package/out-tsc/vitest/src/initialize.d.ts +2 -0
  159. package/out-tsc/vitest/src/initialize.d.ts.map +1 -0
  160. package/out-tsc/vitest/src/mocker/index.d.ts +2 -0
  161. package/out-tsc/vitest/src/mocker/index.d.ts.map +1 -0
  162. package/out-tsc/vitest/src/mocker/registry.d.ts +7 -0
  163. package/out-tsc/vitest/src/mocker/registry.d.ts.map +1 -0
  164. package/out-tsc/vitest/src/mocker/types.d.ts +6 -0
  165. package/out-tsc/vitest/src/mocker/types.d.ts.map +1 -0
  166. package/out-tsc/vitest/src/namespace.d.ts +18 -0
  167. package/out-tsc/vitest/src/namespace.d.ts.map +1 -0
  168. package/out-tsc/vitest/src/runner/errors.d.ts +11 -0
  169. package/out-tsc/vitest/src/runner/errors.d.ts.map +1 -0
  170. package/out-tsc/vitest/src/runner/factory.d.ts +3 -0
  171. package/out-tsc/vitest/src/runner/factory.d.ts.map +1 -0
  172. package/out-tsc/vitest/src/runner/hooks.d.ts +4 -0
  173. package/out-tsc/vitest/src/runner/hooks.d.ts.map +1 -0
  174. package/out-tsc/vitest/src/runner/index.d.ts +4 -0
  175. package/out-tsc/vitest/src/runner/index.d.ts.map +1 -0
  176. package/out-tsc/vitest/src/runner/runSuite.d.ts +4 -0
  177. package/out-tsc/vitest/src/runner/runSuite.d.ts.map +1 -0
  178. package/out-tsc/vitest/src/runner/types.d.ts +13 -0
  179. package/out-tsc/vitest/src/runner/types.d.ts.map +1 -0
  180. package/out-tsc/vitest/src/spy/index.d.ts +2 -0
  181. package/out-tsc/vitest/src/spy/index.d.ts.map +1 -0
  182. package/out-tsc/vitest/src/symbolicate.d.ts +3 -0
  183. package/out-tsc/vitest/src/symbolicate.d.ts.map +1 -0
  184. package/out-tsc/vitest/src/ui/ReadyScreen.d.ts +2 -0
  185. package/out-tsc/vitest/src/ui/ReadyScreen.d.ts.map +1 -0
  186. package/out-tsc/vitest/src/ui/WrongEnvironmentScreen.d.ts +2 -0
  187. package/out-tsc/vitest/src/ui/WrongEnvironmentScreen.d.ts.map +1 -0
  188. package/out-tsc/vitest/src/ui/index.d.ts +2 -0
  189. package/out-tsc/vitest/src/ui/index.d.ts.map +1 -0
  190. package/out-tsc/vitest/src/ui/state.d.ts +7 -0
  191. package/out-tsc/vitest/src/ui/state.d.ts.map +1 -0
  192. package/out-tsc/vitest/src/utils/dev-server.d.ts +2 -0
  193. package/out-tsc/vitest/src/utils/dev-server.d.ts.map +1 -0
  194. package/out-tsc/vitest/src/utils/emitter.d.ts +16 -0
  195. package/out-tsc/vitest/src/utils/emitter.d.ts.map +1 -0
  196. package/out-tsc/vitest/src/waitFor.d.ts +21 -0
  197. package/out-tsc/vitest/src/waitFor.d.ts.map +1 -0
  198. package/out-tsc/vitest/tsconfig.spec.tsbuildinfo +1 -0
  199. package/out-tsc/vitest/vite.config.d.ts +3 -0
  200. package/out-tsc/vitest/vite.config.d.ts.map +1 -0
  201. package/package.json +10 -4
  202. package/src/__tests__/collector.test.ts +55 -55
  203. package/src/__tests__/error-handling.test.ts +34 -34
  204. package/src/__tests__/expect.test.ts +13 -5
  205. package/src/bundler/bundle.ts +1 -2
  206. package/src/bundler/evaluate.ts +9 -9
  207. package/src/bundler/factory.ts +43 -0
  208. package/src/bundler/index.ts +2 -1
  209. package/src/bundler/types.ts +7 -0
  210. package/src/client/factory.ts +51 -16
  211. package/src/client/getDeviceDescriptor.ts +29 -8
  212. package/src/client/setup-files.ts +81 -0
  213. package/src/collector/functions.ts +18 -2
  214. package/src/collector/types.ts +4 -1
  215. package/src/constants.ts +0 -1
  216. package/src/entry-point.ts +8 -0
  217. package/src/expect/index.ts +8 -2
  218. package/src/expect/setup.ts +3 -0
  219. package/src/filtering/index.ts +4 -0
  220. package/src/filtering/testNameFilter.ts +82 -0
  221. package/src/globals.ts +14 -2
  222. package/src/index.ts +3 -0
  223. package/src/initialize.ts +11 -1
  224. package/src/jest-mock.ts +32 -0
  225. package/src/mocker/index.ts +7 -1
  226. package/src/mocker/metro-require.d.ts +2 -0
  227. package/src/mocker/registry.ts +13 -5
  228. package/src/namespace.ts +41 -0
  229. package/src/react-native.d.ts +2 -10
  230. package/src/render/ErrorBoundary.tsx +108 -0
  231. package/src/render/TestComponentOverlay.tsx +47 -0
  232. package/src/render/cleanup.ts +7 -0
  233. package/src/render/index.ts +96 -0
  234. package/src/render/setup.ts +8 -0
  235. package/src/render/types.ts +11 -0
  236. package/src/runner/factory.ts +8 -1
  237. package/src/runner/runSuite.ts +43 -0
  238. package/src/symbolicate.ts +6 -4
  239. package/src/ui/ReadyScreen.tsx +2 -12
  240. package/src/ui/WrongEnvironmentScreen.tsx +1 -19
  241. package/src/ui/state.ts +39 -0
  242. package/src/utils/emitter.ts +1 -0
  243. package/src/waitFor.ts +199 -0
  244. package/tsconfig.spec.json +7 -3
  245. package/tsconfig.tsbuildinfo +1 -1
  246. package/assets/logo.png +0 -0
  247. package/dist/utils/progressLogger.d.ts +0 -8
  248. package/dist/utils/progressLogger.d.ts.map +0 -1
  249. package/dist/utils/progressLogger.js +0 -73
  250. package/src/utils/progressLogger.ts +0 -91
  251. package/types/global.d.ts +0 -2
  252. package/types/index.d.ts +0 -1
@@ -6,8 +6,8 @@ const noop = () => {
6
6
  };
7
7
 
8
8
  describe('test collector - test case recognition', () => {
9
- it('should collect basic test cases using it()', () => {
10
- const collectedSuite = collectorFunctions.collectTests(() => {
9
+ it('should collect basic test cases using it()', async () => {
10
+ const collectedSuite = await collectorFunctions.collectTests(() => {
11
11
  collectorFunctions.describe('Sample Suite', () => {
12
12
  collectorFunctions.it('test 1', noop);
13
13
  collectorFunctions.it('test 2', noop);
@@ -24,8 +24,8 @@ describe('test collector - test case recognition', () => {
24
24
  expect(sampleSuite.tests[1].status).toBe('active');
25
25
  });
26
26
 
27
- it('should collect basic test cases using test()', () => {
28
- const collectedSuite = collectorFunctions.collectTests(() => {
27
+ it('should collect basic test cases using test()', async () => {
28
+ const collectedSuite = await collectorFunctions.collectTests(() => {
29
29
  collectorFunctions.describe('Sample Suite', () => {
30
30
  collectorFunctions.test('test 1', noop);
31
31
  collectorFunctions.test('test 2', noop);
@@ -39,8 +39,8 @@ describe('test collector - test case recognition', () => {
39
39
  expect(sampleSuite.tests[1].name).toBe('test 2');
40
40
  });
41
41
 
42
- it('should collect async test functions', () => {
43
- const collectedSuite = collectorFunctions.collectTests(() => {
42
+ it('should collect async test functions', async () => {
43
+ const collectedSuite = await collectorFunctions.collectTests(() => {
44
44
  collectorFunctions.describe('Async Suite', () => {
45
45
  collectorFunctions.it('async test', async () => {
46
46
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -53,8 +53,8 @@ describe('test collector - test case recognition', () => {
53
53
  expect(typeof asyncSuite.tests[0].fn).toBe('function');
54
54
  });
55
55
 
56
- it('should collect tests at root level', () => {
57
- const collectedSuite = collectorFunctions.collectTests(() => {
56
+ it('should collect tests at root level', async () => {
57
+ const collectedSuite = await collectorFunctions.collectTests(() => {
58
58
  collectorFunctions.it('root test 1', noop);
59
59
  collectorFunctions.test('root test 2', noop);
60
60
 
@@ -76,8 +76,8 @@ describe('test collector - test case recognition', () => {
76
76
  expect(collectedSuite.testSuite.suites[0].tests[0].name).toBe('suite test');
77
77
  });
78
78
 
79
- it('should collect tests with modifiers at root level', () => {
80
- const collectedSuite = collectorFunctions.collectTests(() => {
79
+ it('should collect tests with modifiers at root level', async () => {
80
+ const collectedSuite = await collectorFunctions.collectTests(() => {
81
81
  collectorFunctions.it('regular root test', noop);
82
82
  collectorFunctions.test.skip('skipped root test', noop);
83
83
  collectorFunctions.it.todo('todo root test');
@@ -101,8 +101,8 @@ describe('test collector - test case recognition', () => {
101
101
  });
102
102
 
103
103
  describe('test collector - suite recognition', () => {
104
- it('should collect nested describe blocks', () => {
105
- const collectedSuite = collectorFunctions.collectTests(() => {
104
+ it('should collect nested describe blocks', async () => {
105
+ const collectedSuite = await collectorFunctions.collectTests(() => {
106
106
  collectorFunctions.describe('Outer Suite', () => {
107
107
  collectorFunctions.describe('Inner Suite 1', () => {
108
108
  collectorFunctions.it('test 1', noop);
@@ -123,8 +123,8 @@ describe('test collector - suite recognition', () => {
123
123
  expect(outerSuite.suites[1].tests[0].name).toBe('test 2');
124
124
  });
125
125
 
126
- it('should collect multiple top-level describe blocks', () => {
127
- const collectedSuite = collectorFunctions.collectTests(() => {
126
+ it('should collect multiple top-level describe blocks', async () => {
127
+ const collectedSuite = await collectorFunctions.collectTests(() => {
128
128
  collectorFunctions.describe('Suite 1', () => {
129
129
  collectorFunctions.it('test 1', noop);
130
130
  });
@@ -138,8 +138,8 @@ describe('test collector - suite recognition', () => {
138
138
  expect(collectedSuite.testSuite.suites[1].name).toBe('Suite 2');
139
139
  });
140
140
 
141
- it('should collect deeply nested suites', () => {
142
- const collectedSuite = collectorFunctions.collectTests(() => {
141
+ it('should collect deeply nested suites', async () => {
142
+ const collectedSuite = await collectorFunctions.collectTests(() => {
143
143
  collectorFunctions.describe('Level 1', () => {
144
144
  collectorFunctions.describe('Level 2', () => {
145
145
  collectorFunctions.describe('Level 3', () => {
@@ -161,8 +161,8 @@ describe('test collector - suite recognition', () => {
161
161
  });
162
162
 
163
163
  describe('test collector - skip modifier recognition', () => {
164
- it('should collect and mark skipped tests with test.skip()', () => {
165
- const collectedSuite = collectorFunctions.collectTests(() => {
164
+ it('should collect and mark skipped tests with test.skip()', async () => {
165
+ const collectedSuite = await collectorFunctions.collectTests(() => {
166
166
  collectorFunctions.describe('Skip Suite', () => {
167
167
  collectorFunctions.it('active test', noop);
168
168
  collectorFunctions.test.skip('skipped test', noop);
@@ -177,8 +177,8 @@ describe('test collector - skip modifier recognition', () => {
177
177
  expect(skipSuite.tests[2].status).toBe('skipped');
178
178
  });
179
179
 
180
- it('should collect and mark skipped suites with describe.skip()', () => {
181
- const collectedSuite = collectorFunctions.collectTests(() => {
180
+ it('should collect and mark skipped suites with describe.skip()', async () => {
181
+ const collectedSuite = await collectorFunctions.collectTests(() => {
182
182
  collectorFunctions.describe('Active Suite', () => {
183
183
  collectorFunctions.it('active test', noop);
184
184
  });
@@ -192,8 +192,8 @@ describe('test collector - skip modifier recognition', () => {
192
192
  expect(collectedSuite.testSuite.suites[1].status).toBe('skipped');
193
193
  });
194
194
 
195
- it('should collect nested skipped suites', () => {
196
- const collectedSuite = collectorFunctions.collectTests(() => {
195
+ it('should collect nested skipped suites', async () => {
196
+ const collectedSuite = await collectorFunctions.collectTests(() => {
197
197
  collectorFunctions.describe.skip('Outer Skipped', () => {
198
198
  collectorFunctions.describe('Inner Suite', () => {
199
199
  collectorFunctions.it('test', noop);
@@ -208,8 +208,8 @@ describe('test collector - skip modifier recognition', () => {
208
208
  });
209
209
 
210
210
  describe('test collector - only modifier recognition', () => {
211
- it('should collect and mark only tests and skip others with test.only()', () => {
212
- const collectedSuite = collectorFunctions.collectTests(() => {
211
+ it('should collect and mark only tests and skip others with test.only()', async () => {
212
+ const collectedSuite = await collectorFunctions.collectTests(() => {
213
213
  collectorFunctions.describe('Only Suite', () => {
214
214
  collectorFunctions.it('regular test 1', noop);
215
215
  collectorFunctions.test.only('focused test', noop);
@@ -225,8 +225,8 @@ describe('test collector - only modifier recognition', () => {
225
225
  expect(onlySuite._hasFocused).toBe(true);
226
226
  });
227
227
 
228
- it('should collect multiple test.only() calls', () => {
229
- const collectedSuite = collectorFunctions.collectTests(() => {
228
+ it('should collect multiple test.only() calls', async () => {
229
+ const collectedSuite = await collectorFunctions.collectTests(() => {
230
230
  collectorFunctions.describe('Multiple Only Suite', () => {
231
231
  collectorFunctions.it('regular test', noop);
232
232
  collectorFunctions.test.only('focused test 1', noop);
@@ -240,8 +240,8 @@ describe('test collector - only modifier recognition', () => {
240
240
  expect(multipleSuite.tests[2].status).toBe('active'); // Second only also active
241
241
  });
242
242
 
243
- it('should collect and mark only suites and skip others with describe.only()', () => {
244
- const collectedSuite = collectorFunctions.collectTests(() => {
243
+ it('should collect and mark only suites and skip others with describe.only()', async () => {
244
+ const collectedSuite = await collectorFunctions.collectTests(() => {
245
245
  collectorFunctions.describe('Regular Suite 1', () => {
246
246
  collectorFunctions.it('test 1', noop);
247
247
  });
@@ -260,8 +260,8 @@ describe('test collector - only modifier recognition', () => {
260
260
  expect(collectedSuite.testSuite.suites[1]._hasFocused).toBe(true);
261
261
  });
262
262
 
263
- it('should collect nested describe.only()', () => {
264
- const collectedSuite = collectorFunctions.collectTests(() => {
263
+ it('should collect nested describe.only()', async () => {
264
+ const collectedSuite = await collectorFunctions.collectTests(() => {
265
265
  collectorFunctions.describe('Outer Suite', () => {
266
266
  collectorFunctions.describe('Regular Inner', () => {
267
267
  collectorFunctions.it('test 1', noop);
@@ -281,8 +281,8 @@ describe('test collector - only modifier recognition', () => {
281
281
  });
282
282
 
283
283
  describe('test collector - todo test recognition', () => {
284
- it('should collect and mark todo tests with test.todo()', () => {
285
- const collectedSuite = collectorFunctions.collectTests(() => {
284
+ it('should collect and mark todo tests with test.todo()', async () => {
285
+ const collectedSuite = await collectorFunctions.collectTests(() => {
286
286
  collectorFunctions.describe('Todo Suite', () => {
287
287
  collectorFunctions.it('regular test', noop);
288
288
  collectorFunctions.test.todo('todo test');
@@ -297,8 +297,8 @@ describe('test collector - todo test recognition', () => {
297
297
  expect(todoSuite.tests[2].status).toBe('todo');
298
298
  });
299
299
 
300
- it('should collect todo tests without function bodies', () => {
301
- const collectedSuite = collectorFunctions.collectTests(() => {
300
+ it('should collect todo tests without function bodies', async () => {
301
+ const collectedSuite = await collectorFunctions.collectTests(() => {
302
302
  collectorFunctions.describe('Todo Suite', () => {
303
303
  collectorFunctions.test.todo('implement this feature');
304
304
  });
@@ -312,8 +312,8 @@ describe('test collector - todo test recognition', () => {
312
312
  });
313
313
 
314
314
  describe('test collector - hook recognition', () => {
315
- it('should collect beforeAll hooks', () => {
316
- const collectedSuite = collectorFunctions.collectTests(() => {
315
+ it('should collect beforeAll hooks', async () => {
316
+ const collectedSuite = await collectorFunctions.collectTests(() => {
317
317
  collectorFunctions.describe('Hook Suite', () => {
318
318
  collectorFunctions.beforeAll(() => {
319
319
  // setup
@@ -331,8 +331,8 @@ describe('test collector - hook recognition', () => {
331
331
  expect(typeof hookSuite.beforeAll[1]).toBe('function');
332
332
  });
333
333
 
334
- it('should collect afterAll hooks', () => {
335
- const collectedSuite = collectorFunctions.collectTests(() => {
334
+ it('should collect afterAll hooks', async () => {
335
+ const collectedSuite = await collectorFunctions.collectTests(() => {
336
336
  collectorFunctions.describe('Hook Suite', () => {
337
337
  collectorFunctions.afterAll(() => {
338
338
  // cleanup
@@ -346,8 +346,8 @@ describe('test collector - hook recognition', () => {
346
346
  expect(typeof hookSuite.afterAll[0]).toBe('function');
347
347
  });
348
348
 
349
- it('should collect beforeEach hooks', () => {
350
- const collectedSuite = collectorFunctions.collectTests(() => {
349
+ it('should collect beforeEach hooks', async () => {
350
+ const collectedSuite = await collectorFunctions.collectTests(() => {
351
351
  collectorFunctions.describe('Hook Suite', () => {
352
352
  collectorFunctions.beforeEach(() => {
353
353
  // setup each
@@ -365,8 +365,8 @@ describe('test collector - hook recognition', () => {
365
365
  expect(typeof hookSuite.beforeEach[1]).toBe('function');
366
366
  });
367
367
 
368
- it('should collect afterEach hooks', () => {
369
- const collectedSuite = collectorFunctions.collectTests(() => {
368
+ it('should collect afterEach hooks', async () => {
369
+ const collectedSuite = await collectorFunctions.collectTests(() => {
370
370
  collectorFunctions.describe('Hook Suite', () => {
371
371
  collectorFunctions.afterEach(() => {
372
372
  // cleanup each
@@ -380,8 +380,8 @@ describe('test collector - hook recognition', () => {
380
380
  expect(typeof hookSuite.afterEach[0]).toBe('function');
381
381
  });
382
382
 
383
- it('should collect all types of hooks together', () => {
384
- const collectedSuite = collectorFunctions.collectTests(() => {
383
+ it('should collect all types of hooks together', async () => {
384
+ const collectedSuite = await collectorFunctions.collectTests(() => {
385
385
  collectorFunctions.describe('All Hooks Suite', () => {
386
386
  collectorFunctions.beforeAll(noop);
387
387
  collectorFunctions.afterAll(noop);
@@ -398,8 +398,8 @@ describe('test collector - hook recognition', () => {
398
398
  expect(allHooksSuite.afterEach).toHaveLength(1);
399
399
  });
400
400
 
401
- it('should collect hooks at root level', () => {
402
- const collectedSuite = collectorFunctions.collectTests(() => {
401
+ it('should collect hooks at root level', async () => {
402
+ const collectedSuite = await collectorFunctions.collectTests(() => {
403
403
  collectorFunctions.beforeAll(() => {
404
404
  // root level setup
405
405
  });
@@ -429,8 +429,8 @@ describe('test collector - hook recognition', () => {
429
429
  expect(typeof collectedSuite.testSuite.afterEach[0]).toBe('function');
430
430
  });
431
431
 
432
- it('should collect hooks at both root and suite levels', () => {
433
- const collectedSuite = collectorFunctions.collectTests(() => {
432
+ it('should collect hooks at both root and suite levels', async () => {
433
+ const collectedSuite = await collectorFunctions.collectTests(() => {
434
434
  // Root level hooks
435
435
  collectorFunctions.beforeAll(() => {
436
436
  // global setup
@@ -463,8 +463,8 @@ describe('test collector - hook recognition', () => {
463
463
  });
464
464
 
465
465
  describe('test collector - complex scenarios', () => {
466
- it('should collect mix of tests, suites, hooks, and modifiers', () => {
467
- const collectedSuite = collectorFunctions.collectTests(() => {
466
+ it('should collect mix of tests, suites, hooks, and modifiers', async () => {
467
+ const collectedSuite = await collectorFunctions.collectTests(() => {
468
468
  collectorFunctions.describe('Complex Suite', () => {
469
469
  collectorFunctions.beforeAll(noop);
470
470
  collectorFunctions.beforeEach(noop);
@@ -515,14 +515,14 @@ describe('test collector - complex scenarios', () => {
515
515
  expect(innerSuite.tests[2].status).toBe('skipped'); // Due to .only
516
516
  });
517
517
 
518
- it('should clear collector state between collectTests calls', () => {
519
- const collectedSuite1 = collectorFunctions.collectTests(() => {
518
+ it('should clear collector state between collectTests calls', async () => {
519
+ const collectedSuite1 = await collectorFunctions.collectTests(() => {
520
520
  collectorFunctions.describe('Suite 1', () => {
521
521
  collectorFunctions.it('test 1', noop);
522
522
  });
523
523
  });
524
524
 
525
- const collectedSuite2 = collectorFunctions.collectTests(() => {
525
+ const collectedSuite2 = await collectorFunctions.collectTests(() => {
526
526
  collectorFunctions.describe('Suite 2', () => {
527
527
  collectorFunctions.it('test 2', noop);
528
528
  });
@@ -534,8 +534,8 @@ describe('test collector - complex scenarios', () => {
534
534
  expect(collectedSuite2.testSuite.suites[0].name).toBe('Suite 2');
535
535
  });
536
536
 
537
- it('should collect empty describe blocks', () => {
538
- const collectedSuite = collectorFunctions.collectTests(() => {
537
+ it('should collect empty describe blocks', async () => {
538
+ const collectedSuite = await collectorFunctions.collectTests(() => {
539
539
  collectorFunctions.describe('Empty Suite', () => {
540
540
  // No tests or hooks
541
541
  });
@@ -7,44 +7,44 @@ const noop = () => {
7
7
  };
8
8
 
9
9
  describe('error handling', () => {
10
- it('should throw TestError with proper code for invalid test names', () => {
11
- expect(() => {
10
+ it('should throw TestError with proper code for invalid test names', async () => {
11
+ await expect(() =>
12
12
  harnessRuntime.collectTests(() => {
13
13
  harnessRuntime.describe('Test Suite', () => {
14
14
  harnessRuntime.test('', noop);
15
15
  });
16
- });
17
- }).toThrow(TestError);
16
+ })
17
+ ).rejects.toThrow(TestError);
18
18
 
19
- expect(() => {
19
+ await expect(() =>
20
20
  harnessRuntime.collectTests(() => {
21
21
  harnessRuntime.describe('Test Suite', () => {
22
22
  harnessRuntime.test(null as unknown as string, noop);
23
23
  });
24
- });
25
- }).toThrow(TestError);
24
+ })
25
+ ).rejects.toThrow(TestError);
26
26
  });
27
27
 
28
- it('should throw TestError with proper code for invalid functions', () => {
29
- expect(() => {
28
+ it('should throw TestError with proper code for invalid functions', async () => {
29
+ await expect(() =>
30
30
  harnessRuntime.collectTests(() => {
31
31
  harnessRuntime.describe('Test Suite', () => {
32
32
  // @ts-expect-error - Testing invalid input
33
33
  harnessRuntime.test('test name', null);
34
34
  });
35
- });
36
- }).toThrow(TestError);
35
+ })
36
+ ).rejects.toThrow(TestError);
37
37
  });
38
38
 
39
- it('should throw TestError for duplicate test names', () => {
40
- expect(() => {
39
+ it('should throw TestError for duplicate test names', async () => {
40
+ await expect(() =>
41
41
  harnessRuntime.collectTests(() => {
42
42
  harnessRuntime.describe('Test Suite', () => {
43
43
  harnessRuntime.test('duplicate name', noop);
44
44
  harnessRuntime.test('duplicate name', noop);
45
45
  });
46
- });
47
- }).toThrow(TestError);
46
+ })
47
+ ).rejects.toThrow(TestError);
48
48
  });
49
49
 
50
50
  it('should throw TestError when calling test outside describe', () => {
@@ -71,9 +71,9 @@ describe('error handling', () => {
71
71
  }).toThrow(TestError);
72
72
  });
73
73
 
74
- it('should provide proper error context', () => {
74
+ it('should provide proper error context', async () => {
75
75
  try {
76
- harnessRuntime.collectTests(() => {
76
+ await harnessRuntime.collectTests(() => {
77
77
  harnessRuntime.describe('Test Suite', () => {
78
78
  harnessRuntime.test('test1', noop);
79
79
  harnessRuntime.test('test1', noop);
@@ -89,44 +89,44 @@ describe('error handling', () => {
89
89
  }
90
90
  });
91
91
 
92
- it('should validate describe function inputs', () => {
93
- expect(() => {
92
+ it('should validate describe function inputs', async () => {
93
+ await expect(() =>
94
94
  harnessRuntime.collectTests(() => {
95
95
  harnessRuntime.describe('', noop);
96
- });
97
- }).toThrow(TestError);
96
+ })
97
+ ).rejects.toThrow(TestError);
98
98
 
99
- expect(() => {
99
+ await expect(() =>
100
100
  harnessRuntime.collectTests(() => {
101
101
  // @ts-expect-error - Testing invalid input
102
102
  harnessRuntime.describe('Test Suite', null);
103
- });
104
- }).toThrow(TestError);
103
+ })
104
+ ).rejects.toThrow(TestError);
105
105
  });
106
106
 
107
- it('should validate test modifiers', () => {
108
- expect(() => {
107
+ it('should validate test modifiers', async () => {
108
+ await expect(() =>
109
109
  harnessRuntime.collectTests(() => {
110
110
  harnessRuntime.describe('Test Suite', () => {
111
111
  harnessRuntime.test.skip('', noop);
112
112
  });
113
- });
114
- }).toThrow(TestError);
113
+ })
114
+ ).rejects.toThrow(TestError);
115
115
 
116
- expect(() => {
116
+ await expect(() =>
117
117
  harnessRuntime.collectTests(() => {
118
118
  harnessRuntime.describe('Test Suite', () => {
119
119
  harnessRuntime.test.only('', noop);
120
120
  });
121
- });
122
- }).toThrow(TestError);
121
+ })
122
+ ).rejects.toThrow(TestError);
123
123
 
124
- expect(() => {
124
+ await expect(() =>
125
125
  harnessRuntime.collectTests(() => {
126
126
  harnessRuntime.describe('Test Suite', () => {
127
127
  harnessRuntime.test.todo('');
128
128
  });
129
- });
130
- }).toThrow(TestError);
129
+ })
130
+ ).rejects.toThrow(TestError);
131
131
  });
132
132
  });
@@ -72,7 +72,9 @@ describe('expect - Truthiness', () => {
72
72
  expect('hello').toBeTruthy();
73
73
  expect({}).toBeTruthy();
74
74
  expect([]).toBeTruthy();
75
- expect(function () {}).toBeTruthy();
75
+ expect(function () {
76
+ // noop
77
+ }).toBeTruthy();
76
78
  });
77
79
 
78
80
  test('should fail for falsy values', () => {
@@ -330,7 +332,9 @@ describe('expect - Type Checking', () => {
330
332
  expect(true).toBeTypeOf('boolean');
331
333
  expect(undefined).toBeTypeOf('undefined');
332
334
  expect(Symbol('test')).toBeTypeOf('symbol');
333
- expect(() => {}).toBeTypeOf('function');
335
+ expect(() => {
336
+ // noop
337
+ }).toBeTypeOf('function');
334
338
  expect({}).toBeTypeOf('object');
335
339
  });
336
340
 
@@ -406,7 +410,11 @@ describe('expect - Exceptions', () => {
406
410
  });
407
411
 
408
412
  test('should fail for functions that do not throw', () => {
409
- expect(() => expect(() => {}).toThrow()).toThrow();
413
+ expect(() =>
414
+ expect(() => {
415
+ // noop
416
+ }).toThrow()
417
+ ).toThrow();
410
418
  });
411
419
 
412
420
  test('should fail for wrong error message', () => {
@@ -558,10 +566,10 @@ describe('expect - Custom Messages', () => {
558
566
 
559
567
  describe('expect - Edge Cases', () => {
560
568
  test('should handle circular references', () => {
561
- const circular: any = { a: 1 };
569
+ const circular: Record<string, unknown> = { a: 1 };
562
570
  circular.self = circular;
563
571
 
564
- const circular2: any = { a: 1 };
572
+ const circular2: Record<string, unknown> = { a: 1 };
565
573
  circular2.self = circular2;
566
574
 
567
575
  expect(circular).toEqual(circular2);
@@ -8,10 +8,9 @@ const getModuleUrl = (fileName: string): string => {
8
8
  const urlSearchParams = new URLSearchParams({
9
9
  modulesOnly: 'true',
10
10
  platform: Platform.OS,
11
- 'resolver.isHarness': 'true',
12
11
  });
13
12
 
14
- return `${devServerUrl}/${bundleName}?${urlSearchParams.toString()}`;
13
+ return `${devServerUrl}${bundleName}?${urlSearchParams.toString()}`;
15
14
  };
16
15
 
17
16
  export const fetchModule = async (fileName: string): Promise<string> => {
@@ -1,25 +1,25 @@
1
1
  import { MalformedModuleError } from './errors.js';
2
- import { EnvironmentError } from '../errors.js';
3
2
 
4
3
  export const evaluateModule = (moduleJs: string, modulePath: string): void => {
5
- const __rMatch = moduleJs.match(/__r\((\d+)\)/);
4
+ const __rMatches = Array.from(moduleJs.matchAll(/__r\((\d+)\)/g));
6
5
 
7
- if (!__rMatch) {
6
+ if (__rMatches.length === 0) {
8
7
  throw new MalformedModuleError(modulePath, 'No __r function found');
9
8
  }
10
9
 
10
+ // Get the last match as there may be many require calls
11
+ const __rMatch = __rMatches[__rMatches.length - 1];
11
12
  const __rParam = __rMatch[1];
12
13
 
13
14
  if (!__rParam) {
14
15
  throw new MalformedModuleError(modulePath, 'No __r parameter found');
15
16
  }
16
17
 
17
- // eslint-disable-next-line no-eval
18
- eval(moduleJs);
18
+ const moduleId = Number(__rParam);
19
19
 
20
- if (!__r) {
21
- throw new EnvironmentError('module evaluation', '__r is not defined');
22
- }
20
+ // This is important as if module was already initialized, it would not be re-initialized
21
+ global.__clearModule(moduleId);
23
22
 
24
- __r(Number(__rParam));
23
+ // eslint-disable-next-line no-eval
24
+ eval(moduleJs);
25
25
  };
@@ -0,0 +1,43 @@
1
+ import { BundlerEvents } from '@react-native-harness/bridge';
2
+ import { getEmitter } from '../utils/emitter.js';
3
+ import { Bundler } from './types.js';
4
+ import { fetchModule } from './bundle.js';
5
+ import { BundlingFailedError } from './errors.js';
6
+
7
+ export const getBundler = (): Bundler => {
8
+ const events = getEmitter<BundlerEvents>();
9
+
10
+ return {
11
+ events,
12
+ getModule: async (filePath) => {
13
+ const bundlingStartTime = Date.now();
14
+ events.emit({
15
+ type: 'module-bundling-started',
16
+ file: filePath,
17
+ });
18
+
19
+ try {
20
+ const moduleJs = await fetchModule(filePath);
21
+ events.emit({
22
+ type: 'module-bundling-finished',
23
+ file: filePath,
24
+ duration: Date.now() - bundlingStartTime,
25
+ });
26
+
27
+ return moduleJs;
28
+ } catch (error) {
29
+ events.emit({
30
+ type: 'module-bundling-failed',
31
+ file: filePath,
32
+ duration: Date.now() - bundlingStartTime,
33
+ error:
34
+ error instanceof BundlingFailedError
35
+ ? error.reason
36
+ : 'Unknown error',
37
+ });
38
+
39
+ throw error;
40
+ }
41
+ },
42
+ };
43
+ };
@@ -1,2 +1,3 @@
1
- export { fetchModule } from './bundle.js';
2
1
  export { evaluateModule } from './evaluate.js';
2
+ export { getBundler } from './factory.js';
3
+ export type { Bundler } from './types.js';
@@ -0,0 +1,7 @@
1
+ import { BundlerEvents } from '@react-native-harness/bridge';
2
+ import { EventEmitter } from '../utils/emitter.js';
3
+
4
+ export type Bundler = {
5
+ events: EventEmitter<BundlerEvents>;
6
+ getModule: (filePath: string) => Promise<string>;
7
+ };