@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,279 +0,0 @@
1
- import { TestError } from './errors.js';
2
- import { validateTestName, validateTestFunction } from './validation.js';
3
- // Computation functions for two-phase approach
4
- const computeTestStatus = (test, suiteContext) => {
5
- if (test.options.todo)
6
- return 'todo';
7
- if (test.options.skip)
8
- return 'skipped';
9
- if (test.options.only)
10
- return 'active';
11
- if (suiteContext.hasFocusedTests)
12
- return 'skipped';
13
- return 'active';
14
- };
15
- const computeSuiteStatus = (suite, parentContext) => {
16
- if (suite.options.skip)
17
- return 'skipped';
18
- if (suite.options.only)
19
- return 'active';
20
- // Check if this suite has any focused content (tests or child suites)
21
- const hasFocusedTests = suite.tests.some((test) => test.options.only);
22
- const hasFocusedChildren = suite.suites.some((childSuite) => childSuite.options.only ||
23
- childSuite.tests.some((test) => test.options.only));
24
- // If this suite has focused content, it should be active
25
- if (hasFocusedTests || hasFocusedChildren)
26
- return 'active';
27
- // If parent has focused children and this suite has no focused content, skip it
28
- if (parentContext.hasFocusedChildren)
29
- return 'skipped';
30
- return 'active';
31
- };
32
- const convertRawTestCaseToTestCase = (rawTest, suiteContext) => {
33
- return {
34
- name: rawTest.name,
35
- fn: rawTest.fn,
36
- status: computeTestStatus(rawTest, suiteContext),
37
- };
38
- };
39
- const convertRawTestSuiteToTestSuite = (rawSuite, parentContext = {
40
- hasFocusedChildren: false,
41
- }, parentSuite) => {
42
- // Validate duplicate test names within this suite
43
- const testNames = new Set();
44
- for (const test of rawSuite.tests) {
45
- if (testNames.has(test.name)) {
46
- throw new TestError('DUPLICATE_TEST_NAME', 'test', {
47
- name: test.name,
48
- suiteName: rawSuite.name,
49
- });
50
- }
51
- testNames.add(test.name);
52
- }
53
- // Check if this suite has focused tests
54
- const hasFocusedTests = rawSuite.tests.some((test) => test.options.only);
55
- // Check if this suite has focused children
56
- const hasFocusedChildren = rawSuite.suites.some((suite) => suite.options.only || suite.tests.some((test) => test.options.only));
57
- // Convert tests
58
- const tests = rawSuite.tests.map((test) => convertRawTestCaseToTestCase(test, { hasFocusedTests }));
59
- // Create the suite first so we can reference it when converting children
60
- const suite = {
61
- name: rawSuite.name,
62
- tests,
63
- suites: [],
64
- parent: parentSuite,
65
- beforeAll: rawSuite.hooks.beforeAll,
66
- afterAll: rawSuite.hooks.afterAll,
67
- beforeEach: rawSuite.hooks.beforeEach,
68
- afterEach: rawSuite.hooks.afterEach,
69
- status: computeSuiteStatus(rawSuite, parentContext),
70
- _hasFocused: hasFocusedTests || hasFocusedChildren || rawSuite.options.only,
71
- };
72
- // Convert child suites with this suite as their parent
73
- suite.suites = rawSuite.suites.map((childSuite) => convertRawTestSuiteToTestSuite(childSuite, { hasFocusedChildren }, suite));
74
- return suite;
75
- };
76
- let currentContext = null;
77
- const clearState = () => {
78
- const rootSuite = createRawSuite('root');
79
- return {
80
- rootSuite,
81
- currentSuite: rootSuite,
82
- };
83
- };
84
- const getCurrentSuite = () => {
85
- if (!currentContext) {
86
- throw new TestError('CONTEXT_NOT_INITIALIZED', 'getCurrentSuite');
87
- }
88
- return currentContext.currentSuite;
89
- };
90
- const getRootSuite = () => {
91
- if (!currentContext) {
92
- throw new TestError('CONTEXT_NOT_INITIALIZED', 'getRootSuite');
93
- }
94
- return currentContext.rootSuite;
95
- };
96
- const setCurrentSuite = (suite) => {
97
- if (!currentContext) {
98
- throw new TestError('CONTEXT_NOT_INITIALIZED', 'setCurrentSuite');
99
- }
100
- currentContext.currentSuite = suite;
101
- };
102
- const createRawSuite = (name, options = {}) => {
103
- return {
104
- name,
105
- tests: [],
106
- suites: [],
107
- hooks: {
108
- beforeAll: [],
109
- afterAll: [],
110
- beforeEach: [],
111
- afterEach: [],
112
- },
113
- options,
114
- };
115
- };
116
- export const describe = Object.assign((name, fn) => {
117
- validateTestName(name, 'describe');
118
- validateTestFunction(fn, 'describe');
119
- const suite = createRawSuite(name);
120
- const previousSuite = getCurrentSuite();
121
- setCurrentSuite(suite);
122
- try {
123
- fn();
124
- }
125
- finally {
126
- setCurrentSuite(previousSuite);
127
- }
128
- // Add the suite to its parent
129
- if (previousSuite) {
130
- previousSuite.suites.push(suite);
131
- }
132
- else {
133
- getRootSuite().suites.push(suite);
134
- }
135
- }, {
136
- skip: (name, fn) => {
137
- validateTestName(name, 'describe.skip');
138
- validateTestFunction(fn, 'describe.skip');
139
- const suite = createRawSuite(name, { skip: true });
140
- const previousSuite = getCurrentSuite();
141
- setCurrentSuite(suite);
142
- try {
143
- fn();
144
- }
145
- finally {
146
- setCurrentSuite(previousSuite);
147
- }
148
- // Add the suite to its parent
149
- if (previousSuite) {
150
- previousSuite.suites.push(suite);
151
- }
152
- else {
153
- getRootSuite().suites.push(suite);
154
- }
155
- },
156
- only: (name, fn) => {
157
- validateTestName(name, 'describe.only');
158
- validateTestFunction(fn, 'describe.only');
159
- const suite = createRawSuite(name, { only: true });
160
- const previousSuite = getCurrentSuite();
161
- setCurrentSuite(suite);
162
- try {
163
- fn();
164
- }
165
- finally {
166
- setCurrentSuite(previousSuite);
167
- }
168
- // Add the suite to its parent
169
- if (previousSuite) {
170
- previousSuite.suites.push(suite);
171
- }
172
- else {
173
- getRootSuite().suites.push(suite);
174
- }
175
- },
176
- });
177
- export const test = Object.assign((name, fn) => {
178
- validateTestName(name, 'test');
179
- validateTestFunction(fn, 'test');
180
- const currentSuite = getCurrentSuite();
181
- if (!currentSuite) {
182
- throw new TestError('OUTSIDE_DESCRIBE_BLOCK', 'test');
183
- }
184
- // Add test with default options
185
- currentSuite.tests.push({ name, fn, options: {} });
186
- }, {
187
- skip: (name, fn) => {
188
- validateTestName(name, 'test.skip');
189
- validateTestFunction(fn, 'test.skip');
190
- const currentSuite = getCurrentSuite();
191
- if (!currentSuite) {
192
- throw new TestError('OUTSIDE_DESCRIBE_BLOCK', 'test.skip');
193
- }
194
- currentSuite.tests.push({ name, fn, options: { skip: true } });
195
- },
196
- only: (name, fn) => {
197
- validateTestName(name, 'test.only');
198
- validateTestFunction(fn, 'test.only');
199
- const currentSuite = getCurrentSuite();
200
- if (!currentSuite) {
201
- throw new TestError('OUTSIDE_DESCRIBE_BLOCK', 'test.only');
202
- }
203
- currentSuite.tests.push({ name, fn, options: { only: true } });
204
- },
205
- todo: (name) => {
206
- validateTestName(name, 'test.todo');
207
- const currentSuite = getCurrentSuite();
208
- if (!currentSuite) {
209
- throw new TestError('OUTSIDE_DESCRIBE_BLOCK', 'test.todo');
210
- }
211
- currentSuite.tests.push({
212
- name,
213
- fn: () => {
214
- // Empty function for todo tests
215
- },
216
- options: { todo: true },
217
- });
218
- },
219
- });
220
- export const it = test;
221
- export function beforeAll(fn) {
222
- validateTestFunction(fn, 'beforeAll');
223
- const currentSuite = getCurrentSuite();
224
- if (!currentSuite) {
225
- throw new TestError('OUTSIDE_DESCRIBE_BLOCK', 'beforeAll');
226
- }
227
- currentSuite.hooks.beforeAll.push(fn);
228
- }
229
- export function afterAll(fn) {
230
- validateTestFunction(fn, 'afterAll');
231
- const currentSuite = getCurrentSuite();
232
- if (!currentSuite) {
233
- throw new TestError('OUTSIDE_DESCRIBE_BLOCK', 'afterAll');
234
- }
235
- currentSuite.hooks.afterAll.push(fn);
236
- }
237
- export function beforeEach(fn) {
238
- validateTestFunction(fn, 'beforeEach');
239
- const currentSuite = getCurrentSuite();
240
- if (!currentSuite) {
241
- throw new TestError('OUTSIDE_DESCRIBE_BLOCK', 'beforeEach');
242
- }
243
- currentSuite.hooks.beforeEach.push(fn);
244
- }
245
- export function afterEach(fn) {
246
- validateTestFunction(fn, 'afterEach');
247
- const currentSuite = getCurrentSuite();
248
- if (!currentSuite) {
249
- throw new TestError('OUTSIDE_DESCRIBE_BLOCK', 'afterEach');
250
- }
251
- currentSuite.hooks.afterEach.push(fn);
252
- }
253
- /**
254
- * Recursively counts the total number of tests that will actually be executed.
255
- * Only counts active tests since skipped and todo tests are not executed.
256
- */
257
- const countTests = (suite) => {
258
- let count = suite.tests.filter((test) => test.status === 'active').length;
259
- for (const childSuite of suite.suites) {
260
- count += countTests(childSuite);
261
- }
262
- return count;
263
- };
264
- export const collectTests = async (fn) => {
265
- currentContext = clearState();
266
- try {
267
- await fn();
268
- // Convert raw structure to final structure using computation phase
269
- const testSuite = convertRawTestSuiteToTestSuite(getRootSuite());
270
- const totalTests = countTests(testSuite);
271
- return {
272
- testSuite,
273
- totalTests,
274
- };
275
- }
276
- finally {
277
- currentContext = null;
278
- }
279
- };
@@ -1,5 +0,0 @@
1
- export { describe, test, it, beforeAll, afterAll, beforeEach, afterEach, } from './functions.js';
2
- export { TestError, type TestErrorCode } from './errors.js';
3
- export type { TestCollector, TestCollectorEventsEmitter } from './types.js';
4
- export { getTestCollector } from './factory.js';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,EAAE,EACF,SAAS,EACT,QAAQ,EACR,UAAU,EACV,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
@@ -1,3 +0,0 @@
1
- export { describe, test, it, beforeAll, afterAll, beforeEach, afterEach, } from './functions.js';
2
- export { TestError } from './errors.js';
3
- export { getTestCollector } from './factory.js';
@@ -1,10 +0,0 @@
1
- import { EventEmitter } from '../utils/emitter.js';
2
- import { TestCollectorEvents, CollectionResult } from '@react-native-harness/bridge';
3
- export type TestFn = () => void | Promise<void>;
4
- export type TestCollectorEventsEmitter = EventEmitter<TestCollectorEvents>;
5
- export type TestCollector = {
6
- events: TestCollectorEventsEmitter;
7
- collect: (fn: () => void | Promise<void>, testFilePath: string) => Promise<CollectionResult>;
8
- dispose: () => void;
9
- };
10
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/collector/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,MAAM,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhD,MAAM,MAAM,0BAA0B,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAE3E,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,0BAA0B,CAAC;IACnC,OAAO,EAAE,CACP,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC9B,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import { TestFn } from './types.js';
2
- export declare const validateTestName: (name: string, functionName: string) => void;
3
- export declare const validateTestFunction: (fn: TestFn, functionName: string) => void;
4
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/collector/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,cAAc,MAAM,KAAG,IAMrE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,IAAI,MAAM,EACV,cAAc,MAAM,KACnB,IAMF,CAAC"}
@@ -1,15 +0,0 @@
1
- import { TestError } from './errors.js';
2
- export const validateTestName = (name, functionName) => {
3
- if (!name || typeof name !== 'string' || name.trim() === '') {
4
- throw new TestError('INVALID_TEST_NAME', functionName, {
5
- name,
6
- });
7
- }
8
- };
9
- export const validateTestFunction = (fn, functionName) => {
10
- if (typeof fn !== 'function') {
11
- throw new TestError('INVALID_FUNCTION', functionName, {
12
- functionType: typeof fn,
13
- });
14
- }
15
- };
@@ -1,2 +0,0 @@
1
- export declare const WS_SERVER_PORT = 3001;
2
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,OAAO,CAAC"}
package/dist/constants.js DELETED
@@ -1 +0,0 @@
1
- export const WS_SERVER_PORT = 3001;
@@ -1,2 +0,0 @@
1
- export declare function disableHMRWhenReady(disable: () => void, retriesLeft: number, retryDelay?: number): Promise<void>;
2
- //# sourceMappingURL=disableHMRWhenReady.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"disableHMRWhenReady.d.ts","sourceRoot":"","sources":["../src/disableHMRWhenReady.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,IAAI,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,SAAK,iBAuBhB"}
@@ -1,20 +0,0 @@
1
- export function disableHMRWhenReady(disable, retriesLeft, retryDelay = 10) {
2
- return new Promise((resolve, reject) => {
3
- function attempt(remaining) {
4
- try {
5
- disable();
6
- resolve();
7
- }
8
- catch (error) {
9
- if (remaining > 0 &&
10
- error instanceof Error &&
11
- error.message.includes('Expected HMRClient.setup() call at startup.')) {
12
- setTimeout(() => attempt(remaining - 1), retryDelay);
13
- return;
14
- }
15
- reject(error);
16
- }
17
- }
18
- attempt(retriesLeft);
19
- });
20
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=entry-point.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entry-point.d.ts","sourceRoot":"","sources":["../src/entry-point.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- import { AppRegistry } from 'react-native';
2
- import { getHarnessGlobal } from './globals.js';
3
- import { UI } from './ui/index.js';
4
- AppRegistry.registerComponent(getHarnessGlobal().appRegistryComponentName, () => UI);
package/dist/errors.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare class EnvironmentError extends Error {
2
- readonly context: string;
3
- readonly details?: string | undefined;
4
- constructor(context: string, details?: string | undefined);
5
- }
6
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;aAEvB,OAAO,EAAE,MAAM;aACf,OAAO,CAAC,EAAE,MAAM;gBADhB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,YAAA;CAQnC"}
package/dist/errors.js DELETED
@@ -1,13 +0,0 @@
1
- export class EnvironmentError extends Error {
2
- context;
3
- details;
4
- constructor(context, details) {
5
- const message = details
6
- ? `Environment error in ${context}: ${details}`
7
- : `Environment error: ${context}`;
8
- super(message);
9
- this.context = context;
10
- this.details = details;
11
- this.name = 'EnvironmentError';
12
- }
13
- }
@@ -1,9 +0,0 @@
1
- import type { ExpectStatic } from '@vitest/expect';
2
- import * as chai from 'chai';
3
- import './setup.js';
4
- export declare function createExpect(): ExpectStatic;
5
- declare const globalExpect: ExpectStatic;
6
- export { assert, should } from 'chai';
7
- export { chai, globalExpect as expect };
8
- export type { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectStatic, JestAssertion, Matchers, } from '@vitest/expect';
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expect/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAa,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAS5E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,YAAY,CAAC;AAEpB,wBAAgB,YAAY,IAAI,YAAY,CAqF3C;AAED,QAAA,MAAM,YAAY,EAAE,YAA6B,CAAC;AAQlD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,YAAY,IAAI,MAAM,EAAE,CAAC;AAExC,YAAY,EACV,SAAS,EACT,4BAA4B,EAC5B,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,QAAQ,GACT,MAAM,gBAAgB,CAAC"}
@@ -1,73 +0,0 @@
1
- // This is adapted version of https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/integrations/chai/index.ts
2
- // Credits to Vitest team for the original implementation.
3
- import { addCustomEqualityTesters, ASYMMETRIC_MATCHERS_OBJECT, customMatchers, getState, GLOBAL_EXPECT, setState, } from '@vitest/expect';
4
- import * as chai from 'chai';
5
- // Setup additional matchers
6
- import './setup.js';
7
- export function createExpect() {
8
- const expect = ((value, message) => {
9
- const { assertionCalls } = getState(expect);
10
- setState({ assertionCalls: assertionCalls + 1 }, expect);
11
- return chai.expect(value, message);
12
- });
13
- Object.assign(expect, chai.expect);
14
- Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
15
- expect.getState = () => getState(expect);
16
- expect.setState = (state) => setState(state, expect);
17
- // @ts-expect-error global is not typed
18
- const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
19
- setState({
20
- // this should also add "snapshotState" that is added conditionally
21
- ...globalState,
22
- assertionCalls: 0,
23
- isExpectingAssertions: false,
24
- isExpectingAssertionsError: null,
25
- expectedAssertionsNumber: null,
26
- expectedAssertionsNumberErrorGen: null,
27
- }, expect);
28
- // @ts-expect-error untyped
29
- expect.extend = (matchers) => chai.expect.extend(expect, matchers);
30
- // @ts-expect-error untyped
31
- expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
32
- // @ts-expect-error untyped
33
- expect.soft = (...args) => {
34
- // @ts-expect-error private soft access
35
- return expect(...args).withContext({ soft: true });
36
- };
37
- // @ts-expect-error untyped
38
- expect.unreachable = (message) => {
39
- chai.assert.fail(`expected${message ? ` "${message}" ` : ' '}not to be reached`);
40
- };
41
- function assertions(expected) {
42
- const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect.getState().assertionCalls}`);
43
- if (Error.captureStackTrace) {
44
- Error.captureStackTrace(errorGen(), assertions);
45
- }
46
- expect.setState({
47
- expectedAssertionsNumber: expected,
48
- expectedAssertionsNumberErrorGen: errorGen,
49
- });
50
- }
51
- function hasAssertions() {
52
- const error = new Error('expected any number of assertion, but got none');
53
- if (Error.captureStackTrace) {
54
- Error.captureStackTrace(error, hasAssertions);
55
- }
56
- expect.setState({
57
- isExpectingAssertions: true,
58
- isExpectingAssertionsError: error,
59
- });
60
- }
61
- chai.util.addMethod(expect, 'assertions', assertions);
62
- chai.util.addMethod(expect, 'hasAssertions', hasAssertions);
63
- expect.extend(customMatchers);
64
- return expect;
65
- }
66
- const globalExpect = createExpect();
67
- Object.defineProperty(globalThis, GLOBAL_EXPECT, {
68
- value: globalExpect,
69
- writable: true,
70
- configurable: true,
71
- });
72
- export { assert, should } from 'chai';
73
- export { chai, globalExpect as expect };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/expect/setup.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- // This is adapted version of https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/integrations/chai/setup.ts
2
- // Credits to Vitest team for the original implementation.
3
- import { JestAsymmetricMatchers, JestChaiExpect, JestExtend, } from '@vitest/expect';
4
- import * as chai from 'chai';
5
- chai.use(JestExtend);
6
- chai.use(JestChaiExpect);
7
- chai.use(JestAsymmetricMatchers);
@@ -1,2 +0,0 @@
1
- export { filterTestsByName, markTestsAsSkippedByName, } from './testNameFilter.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filtering/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC"}
@@ -1 +0,0 @@
1
- export { filterTestsByName, markTestsAsSkippedByName, } from './testNameFilter.js';
@@ -1,12 +0,0 @@
1
- import { TestSuite } from '@react-native-harness/bridge';
2
- /**
3
- * Filters tests by name pattern, matching against test names and suite+test combinations
4
- * @deprecated Use markTestsAsSkippedByName instead - this function will be removed in a future version
5
- */
6
- export declare const filterTestsByName: (suite: TestSuite, testNamePattern: string) => TestSuite;
7
- /**
8
- * Marks tests as skipped based on name pattern, keeping all tests in the structure
9
- * but setting non-matching tests to 'skipped' status
10
- */
11
- export declare const markTestsAsSkippedByName: (suite: TestSuite, testNamePattern: string) => TestSuite;
12
- //# sourceMappingURL=testNameFilter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testNameFilter.d.ts","sourceRoot":"","sources":["../../src/filtering/testNameFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,SAAS,EAChB,iBAAiB,MAAM,KACtB,SAGF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,SAAS,EAChB,iBAAiB,MAAM,KACtB,SAGF,CAAC"}
@@ -1,56 +0,0 @@
1
- /**
2
- * Filters tests by name pattern, matching against test names and suite+test combinations
3
- * @deprecated Use markTestsAsSkippedByName instead - this function will be removed in a future version
4
- */
5
- export const filterTestsByName = (suite, testNamePattern) => {
6
- const regex = new RegExp(testNamePattern);
7
- return filterSuiteRecursively(suite, regex);
8
- };
9
- /**
10
- * Marks tests as skipped based on name pattern, keeping all tests in the structure
11
- * but setting non-matching tests to 'skipped' status
12
- */
13
- export const markTestsAsSkippedByName = (suite, testNamePattern) => {
14
- const regex = new RegExp(testNamePattern);
15
- return markTestsRecursively(suite, regex);
16
- };
17
- const markTestsRecursively = (suite, regex) => {
18
- // Mark tests in current suite - skip tests that don't match the pattern
19
- const updatedTests = suite.tests.map((test) => {
20
- const matches = regex.test(test.name) || regex.test(`${suite.name} ${test.name}`);
21
- // If test doesn't match pattern and is currently active, mark it as skipped
22
- if (!matches && test.status === 'active') {
23
- return {
24
- ...test,
25
- status: 'skipped',
26
- };
27
- }
28
- // Keep original status for matching tests or already skipped/todo tests
29
- return test;
30
- });
31
- // Recursively process child suites
32
- const updatedChildSuites = suite.suites.map((childSuite) => markTestsRecursively(childSuite, regex));
33
- return {
34
- ...suite,
35
- tests: updatedTests,
36
- suites: updatedChildSuites,
37
- };
38
- };
39
- const filterSuiteRecursively = (suite, regex) => {
40
- // Filter tests in current suite - match against test name or "suite test" combination
41
- const filteredTests = suite.tests.filter((test) => regex.test(test.name) || regex.test(`${suite.name} ${test.name}`));
42
- // Recursively filter child suites
43
- const filteredChildSuites = suite.suites
44
- .map((childSuite) => filterSuiteRecursively(childSuite, regex))
45
- .filter((childSuite) => hasAnyActiveTests(childSuite));
46
- return {
47
- ...suite,
48
- tests: filteredTests,
49
- suites: filteredChildSuites,
50
- };
51
- };
52
- const hasAnyActiveTests = (suite) => {
53
- const hasDirectTests = suite.tests.some((test) => test.status === 'active');
54
- const hasChildTests = suite.suites.some((childSuite) => hasAnyActiveTests(childSuite));
55
- return hasDirectTests || hasChildTests;
56
- };
package/dist/globals.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export type HarnessGlobal = {
2
- appRegistryComponentName: string;
3
- webSocketPort?: number;
4
- };
5
- declare global {
6
- var RN_HARNESS: HarnessGlobal | undefined;
7
- }
8
- export declare const getHarnessGlobal: () => HarnessGlobal;
9
- //# sourceMappingURL=globals.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,wBAAwB,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,UAAU,EAAE,aAAa,GAAG,SAAS,CAAC;CAC3C;AAED,eAAO,MAAM,gBAAgB,QAAO,aAQnC,CAAC"}
package/dist/globals.js DELETED
@@ -1,7 +0,0 @@
1
- export const getHarnessGlobal = () => {
2
- const harnessGlobal = global.RN_HARNESS;
3
- if (!harnessGlobal) {
4
- throw new Error('RN_HARNESS global is not set');
5
- }
6
- return harnessGlobal;
7
- };
package/dist/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import './polyfills.js';
2
- import './globals.d.ts';
3
- export { UI as ReactNativeHarness } from './ui/index.js';
4
- export * from './spy/index.js';
5
- export * from './expect/index.js';
6
- export * from './collector/index.js';
7
- export * from './mocker/index.js';
8
- export * from './namespace.js';
9
- export * from './waitFor.js';
10
- export * from './render/index.js';
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AACxB,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,EAAE,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACzD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=initialize.d.ts.map