@react-native-harness/runtime 1.0.0-alpha.1 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundler/bundle.d.ts.map +1 -1
- package/dist/bundler/bundle.js +6 -1
- package/dist/bundler/errors.d.ts +5 -0
- package/dist/bundler/errors.d.ts.map +1 -1
- package/dist/bundler/errors.js +10 -0
- package/dist/mocker/registry.d.ts +2 -2
- package/dist/mocker/registry.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/bundler/bundle.ts +8 -1
- package/src/bundler/errors.ts +10 -0
- package/src/mocker/registry.ts +3 -3
- package/dist/bundler/dev-server.d.ts +0 -2
- package/dist/bundler/dev-server.d.ts.map +0 -1
- package/dist/bundler/dev-server.js +0 -5
- package/dist/exports.d.ts +0 -7
- package/dist/exports.d.ts.map +0 -1
- package/dist/exports.js +0 -6
- package/dist/getEntryComponent.d.ts +0 -6
- package/dist/getEntryComponent.d.ts.map +0 -1
- package/dist/getEntryComponent.js +0 -6
- package/dist/logger.d.ts +0 -6
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -14
- package/dist/mock.d.ts +0 -15
- package/dist/mock.d.ts.map +0 -1
- package/dist/mock.js +0 -37
- package/dist/module.d.ts +0 -3
- package/dist/module.d.ts.map +0 -1
- package/dist/module.js +0 -19
- package/dist/module.web.d.ts +0 -2
- package/dist/module.web.d.ts.map +0 -1
- package/dist/module.web.js +0 -12
- package/dist/rntl/client.d.ts +0 -3
- package/dist/rntl/client.d.ts.map +0 -1
- package/dist/rntl/client.js +0 -8
- package/dist/rntl/describe.d.ts +0 -2
- package/dist/rntl/describe.d.ts.map +0 -1
- package/dist/rntl/describe.js +0 -1
- package/dist/rntl/expect.d.ts +0 -128
- package/dist/rntl/expect.d.ts.map +0 -1
- package/dist/rntl/expect.js +0 -670
- package/dist/rntl/fn.d.ts +0 -2
- package/dist/rntl/fn.d.ts.map +0 -1
- package/dist/rntl/fn.js +0 -1
- package/dist/rntl/mock.d.ts +0 -2
- package/dist/rntl/mock.d.ts.map +0 -1
- package/dist/rntl/mock.js +0 -1
- package/dist/rntl/render.d.ts +0 -4
- package/dist/rntl/render.d.ts.map +0 -1
- package/dist/rntl/render.js +0 -11
- package/dist/rntl/screen.d.ts +0 -45
- package/dist/rntl/screen.d.ts.map +0 -1
- package/dist/rntl/screen.js +0 -31
- package/dist/rntl/spies.d.ts +0 -45
- package/dist/rntl/spies.d.ts.map +0 -1
- package/dist/rntl/spies.js +0 -553
- package/dist/rntl/userEvent.d.ts +0 -22
- package/dist/rntl/userEvent.d.ts.map +0 -1
- package/dist/rntl/userEvent.js +0 -19
- package/dist/runner.d.ts +0 -7
- package/dist/runner.d.ts.map +0 -1
- package/dist/runner.js +0 -201
- package/dist/runtime.d.ts +0 -2
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -44
- package/dist/state.d.ts +0 -25
- package/dist/state.d.ts.map +0 -1
- package/dist/state.js +0 -37
- package/dist/ui/UI.d.ts +0 -13
- package/dist/ui/UI.d.ts.map +0 -1
- package/dist/ui/UI.js +0 -121
package/dist/rntl/spies.js
DELETED
|
@@ -1,553 +0,0 @@
|
|
|
1
|
-
import * as sinon from 'sinon';
|
|
2
|
-
// 'any' is needed to accept 'any' functions
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
-
const sandbox = sinon.createSandbox();
|
|
5
|
-
export const clearAllSpies = () => {
|
|
6
|
-
sandbox.restore();
|
|
7
|
-
};
|
|
8
|
-
export const fn = (implementation) => {
|
|
9
|
-
const stub = sandbox.stub();
|
|
10
|
-
// Arrays to track instances and contexts manually
|
|
11
|
-
const instances = [];
|
|
12
|
-
const contexts = [];
|
|
13
|
-
// Store the original implementation
|
|
14
|
-
const originalImplementation = implementation;
|
|
15
|
-
// Create a wrapper that captures context and instances
|
|
16
|
-
const wrappedFunction = function (...args) {
|
|
17
|
-
// Capture the context (this value)
|
|
18
|
-
contexts.push(this);
|
|
19
|
-
// If called as constructor, capture the instance
|
|
20
|
-
if (new.target) {
|
|
21
|
-
const instance = Object.create(this.constructor?.prototype || {});
|
|
22
|
-
instances.push(instance);
|
|
23
|
-
// If there's an implementation, call it in constructor context
|
|
24
|
-
if (originalImplementation) {
|
|
25
|
-
const result = originalImplementation.apply(instance, args);
|
|
26
|
-
return result !== undefined ? result : instance;
|
|
27
|
-
}
|
|
28
|
-
return instance;
|
|
29
|
-
}
|
|
30
|
-
// Normal function call - call the original implementation if available
|
|
31
|
-
if (originalImplementation) {
|
|
32
|
-
return originalImplementation.apply(this, args);
|
|
33
|
-
}
|
|
34
|
-
// No implementation, return undefined
|
|
35
|
-
return undefined;
|
|
36
|
-
};
|
|
37
|
-
// Set up the initial behavior
|
|
38
|
-
stub.callsFake(wrappedFunction);
|
|
39
|
-
const jestSpy = Object.assign(stub, {
|
|
40
|
-
mock: {
|
|
41
|
-
calls: [],
|
|
42
|
-
instances,
|
|
43
|
-
contexts,
|
|
44
|
-
results: [],
|
|
45
|
-
lastCall: null,
|
|
46
|
-
},
|
|
47
|
-
mockClear: () => {
|
|
48
|
-
// Clear sinon internal data (the getters will now return empty arrays)
|
|
49
|
-
stub.resetHistory();
|
|
50
|
-
// Clear other mock tracking data that we manage directly
|
|
51
|
-
instances.length = 0;
|
|
52
|
-
contexts.length = 0;
|
|
53
|
-
return jestSpy;
|
|
54
|
-
},
|
|
55
|
-
mockReset: () => {
|
|
56
|
-
jestSpy.mockClear();
|
|
57
|
-
stub.resetBehavior();
|
|
58
|
-
return jestSpy;
|
|
59
|
-
},
|
|
60
|
-
mockRestore: () => {
|
|
61
|
-
if (stub.restore) {
|
|
62
|
-
stub.restore();
|
|
63
|
-
}
|
|
64
|
-
return jestSpy;
|
|
65
|
-
},
|
|
66
|
-
mockReturnValue: (value) => {
|
|
67
|
-
// Update the wrapper to always return the specified value
|
|
68
|
-
const returnWrapper = function (...args) {
|
|
69
|
-
contexts.push(this);
|
|
70
|
-
if (new.target) {
|
|
71
|
-
const instance = Object.create({});
|
|
72
|
-
instances.push(instance);
|
|
73
|
-
return value !== undefined ? value : instance;
|
|
74
|
-
}
|
|
75
|
-
return value;
|
|
76
|
-
};
|
|
77
|
-
stub.callsFake(returnWrapper);
|
|
78
|
-
return jestSpy;
|
|
79
|
-
},
|
|
80
|
-
mockReturnValueOnce: (value) => {
|
|
81
|
-
stub
|
|
82
|
-
.onCall(stub.callCount)
|
|
83
|
-
.callsFake(function (...args) {
|
|
84
|
-
contexts.push(this);
|
|
85
|
-
if (new.target) {
|
|
86
|
-
const instance = Object.create({});
|
|
87
|
-
instances.push(instance);
|
|
88
|
-
return value !== undefined ? value : instance;
|
|
89
|
-
}
|
|
90
|
-
return value;
|
|
91
|
-
});
|
|
92
|
-
return jestSpy;
|
|
93
|
-
},
|
|
94
|
-
mockResolvedValue: (value) => {
|
|
95
|
-
const promiseWrapper = function (...args) {
|
|
96
|
-
contexts.push(this);
|
|
97
|
-
if (new.target) {
|
|
98
|
-
const instance = Object.create({});
|
|
99
|
-
instances.push(instance);
|
|
100
|
-
return Promise.resolve(value);
|
|
101
|
-
}
|
|
102
|
-
return Promise.resolve(value);
|
|
103
|
-
};
|
|
104
|
-
stub.callsFake(promiseWrapper);
|
|
105
|
-
return jestSpy;
|
|
106
|
-
},
|
|
107
|
-
mockResolvedValueOnce: (value) => {
|
|
108
|
-
stub
|
|
109
|
-
.onCall(stub.callCount)
|
|
110
|
-
.callsFake(function (...args) {
|
|
111
|
-
contexts.push(this);
|
|
112
|
-
if (new.target) {
|
|
113
|
-
const instance = Object.create({});
|
|
114
|
-
instances.push(instance);
|
|
115
|
-
return Promise.resolve(value);
|
|
116
|
-
}
|
|
117
|
-
return Promise.resolve(value);
|
|
118
|
-
});
|
|
119
|
-
return jestSpy;
|
|
120
|
-
},
|
|
121
|
-
mockRejectedValue: (value) => {
|
|
122
|
-
const rejectWrapper = function (...args) {
|
|
123
|
-
contexts.push(this);
|
|
124
|
-
if (new.target) {
|
|
125
|
-
const instance = Object.create({});
|
|
126
|
-
instances.push(instance);
|
|
127
|
-
return Promise.reject(value);
|
|
128
|
-
}
|
|
129
|
-
return Promise.reject(value);
|
|
130
|
-
};
|
|
131
|
-
stub.callsFake(rejectWrapper);
|
|
132
|
-
return jestSpy;
|
|
133
|
-
},
|
|
134
|
-
mockRejectedValueOnce: (value) => {
|
|
135
|
-
stub
|
|
136
|
-
.onCall(stub.callCount)
|
|
137
|
-
.callsFake(function (...args) {
|
|
138
|
-
contexts.push(this);
|
|
139
|
-
if (new.target) {
|
|
140
|
-
const instance = Object.create({});
|
|
141
|
-
instances.push(instance);
|
|
142
|
-
return Promise.reject(value);
|
|
143
|
-
}
|
|
144
|
-
return Promise.reject(value);
|
|
145
|
-
});
|
|
146
|
-
return jestSpy;
|
|
147
|
-
},
|
|
148
|
-
mockImplementation: (fn) => {
|
|
149
|
-
// Update the wrapper to use the new implementation
|
|
150
|
-
const newWrapper = function (...args) {
|
|
151
|
-
contexts.push(this);
|
|
152
|
-
if (new.target) {
|
|
153
|
-
const instance = Object.create(fn.prototype || {});
|
|
154
|
-
instances.push(instance);
|
|
155
|
-
const result = fn.apply(instance, args);
|
|
156
|
-
return result !== undefined ? result : instance;
|
|
157
|
-
}
|
|
158
|
-
return fn.apply(this, args);
|
|
159
|
-
};
|
|
160
|
-
stub.callsFake(newWrapper);
|
|
161
|
-
return jestSpy;
|
|
162
|
-
},
|
|
163
|
-
mockImplementationOnce: (fn) => {
|
|
164
|
-
stub.onCall(stub.callCount).callsFake(fn);
|
|
165
|
-
return jestSpy;
|
|
166
|
-
},
|
|
167
|
-
// Convenience methods for Jest compatibility
|
|
168
|
-
toHaveBeenCalled: () => stub.called,
|
|
169
|
-
toHaveBeenCalledTimes: (expected) => stub.callCount === expected,
|
|
170
|
-
toHaveBeenCalledWith: (...args) => {
|
|
171
|
-
return stub
|
|
172
|
-
.getCalls()
|
|
173
|
-
.some((call) => call.args.length === args.length &&
|
|
174
|
-
call.args.every((arg, index) => arg === args[index]));
|
|
175
|
-
},
|
|
176
|
-
toHaveBeenLastCalledWith: (...args) => {
|
|
177
|
-
const calls = stub.getCalls();
|
|
178
|
-
if (calls.length === 0)
|
|
179
|
-
return false;
|
|
180
|
-
const lastCall = calls[calls.length - 1];
|
|
181
|
-
return (lastCall.args.length === args.length &&
|
|
182
|
-
lastCall.args.every((arg, index) => arg === args[index]));
|
|
183
|
-
},
|
|
184
|
-
toHaveBeenNthCalledWith: (nthCall, ...args) => {
|
|
185
|
-
const calls = stub.getCalls();
|
|
186
|
-
if (nthCall < 1 || nthCall > calls.length)
|
|
187
|
-
return false;
|
|
188
|
-
const call = calls[nthCall - 1];
|
|
189
|
-
return (call.args.length === args.length &&
|
|
190
|
-
call.args.every((arg, index) => arg === args[index]));
|
|
191
|
-
},
|
|
192
|
-
toHaveReturnedWith: (value) => {
|
|
193
|
-
return stub.getCalls().some((call) => call.returnValue === value);
|
|
194
|
-
},
|
|
195
|
-
toHaveLastReturnedWith: (value) => {
|
|
196
|
-
const calls = stub.getCalls();
|
|
197
|
-
if (calls.length === 0)
|
|
198
|
-
return false;
|
|
199
|
-
return calls[calls.length - 1].returnValue === value;
|
|
200
|
-
},
|
|
201
|
-
toHaveNthReturnedWith: (nthCall, value) => {
|
|
202
|
-
const calls = stub.getCalls();
|
|
203
|
-
if (nthCall < 1 || nthCall > calls.length)
|
|
204
|
-
return false;
|
|
205
|
-
return calls[nthCall - 1].returnValue === value;
|
|
206
|
-
},
|
|
207
|
-
toHaveReturnedTimes: (expected) => {
|
|
208
|
-
return (stub.getCalls().filter((call) => !call.exception).length === expected);
|
|
209
|
-
},
|
|
210
|
-
// Promise-specific helpers
|
|
211
|
-
toHaveResolvedWith: async (value) => {
|
|
212
|
-
const calls = stub.getCalls();
|
|
213
|
-
for (const call of calls) {
|
|
214
|
-
if (call.returnValue && typeof call.returnValue.then === 'function') {
|
|
215
|
-
try {
|
|
216
|
-
const resolved = await call.returnValue;
|
|
217
|
-
if (resolved === value)
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
catch {
|
|
221
|
-
// Promise rejected, skip
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return false;
|
|
226
|
-
},
|
|
227
|
-
toHaveRejectedWith: async (value) => {
|
|
228
|
-
const calls = stub.getCalls();
|
|
229
|
-
for (const call of calls) {
|
|
230
|
-
if (call.returnValue && typeof call.returnValue.catch === 'function') {
|
|
231
|
-
try {
|
|
232
|
-
await call.returnValue;
|
|
233
|
-
// Promise resolved, skip
|
|
234
|
-
}
|
|
235
|
-
catch (error) {
|
|
236
|
-
if (error === value)
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return false;
|
|
242
|
-
},
|
|
243
|
-
mockReturnThis: () => {
|
|
244
|
-
const thisWrapper = function (...args) {
|
|
245
|
-
contexts.push(this);
|
|
246
|
-
if (new.target) {
|
|
247
|
-
const instance = Object.create({});
|
|
248
|
-
instances.push(instance);
|
|
249
|
-
return instance;
|
|
250
|
-
}
|
|
251
|
-
return this;
|
|
252
|
-
};
|
|
253
|
-
stub.callsFake(thisWrapper);
|
|
254
|
-
return jestSpy;
|
|
255
|
-
},
|
|
256
|
-
});
|
|
257
|
-
// Override the mock object's getters to provide real-time data
|
|
258
|
-
Object.defineProperty(jestSpy.mock, 'calls', {
|
|
259
|
-
get: () => {
|
|
260
|
-
return stub.getCalls().map((call) => call.args);
|
|
261
|
-
},
|
|
262
|
-
enumerable: true,
|
|
263
|
-
});
|
|
264
|
-
Object.defineProperty(jestSpy.mock, 'lastCall', {
|
|
265
|
-
get: () => {
|
|
266
|
-
const calls = stub.getCalls().map((call) => call.args);
|
|
267
|
-
return calls.length > 0 ? calls[calls.length - 1] : null;
|
|
268
|
-
},
|
|
269
|
-
enumerable: true,
|
|
270
|
-
});
|
|
271
|
-
Object.defineProperty(jestSpy.mock, 'results', {
|
|
272
|
-
get: () => {
|
|
273
|
-
return stub.getCalls().map((call) => {
|
|
274
|
-
if (call.exception) {
|
|
275
|
-
return { type: 'throw', value: call.exception };
|
|
276
|
-
}
|
|
277
|
-
return { type: 'return', value: call.returnValue };
|
|
278
|
-
});
|
|
279
|
-
},
|
|
280
|
-
enumerable: true,
|
|
281
|
-
});
|
|
282
|
-
return jestSpy;
|
|
283
|
-
};
|
|
284
|
-
export const spyOn = (obj, method) => {
|
|
285
|
-
const stub = sandbox.stub(obj, method);
|
|
286
|
-
// Arrays to track instances and contexts manually
|
|
287
|
-
const instances = [];
|
|
288
|
-
const contexts = [];
|
|
289
|
-
// Store original method to capture context and instances
|
|
290
|
-
const originalMethod = obj[method];
|
|
291
|
-
// Create a wrapper that captures context and instances
|
|
292
|
-
const spyWrapper = function (...args) {
|
|
293
|
-
// Capture the context (this value)
|
|
294
|
-
contexts.push(this);
|
|
295
|
-
// If called as constructor, capture the instance
|
|
296
|
-
if (new.target && typeof originalMethod === 'function') {
|
|
297
|
-
const instance = Object.create(originalMethod.prototype || {});
|
|
298
|
-
instances.push(instance);
|
|
299
|
-
// Call original method as constructor
|
|
300
|
-
return originalMethod.apply(instance, args) || instance;
|
|
301
|
-
}
|
|
302
|
-
// Normal function call - use the original method
|
|
303
|
-
return originalMethod.apply(this, args);
|
|
304
|
-
};
|
|
305
|
-
// Set up the spy wrapper
|
|
306
|
-
stub.callsFake(spyWrapper);
|
|
307
|
-
const jestSpy = Object.assign(stub, {
|
|
308
|
-
mock: {
|
|
309
|
-
calls: [],
|
|
310
|
-
instances,
|
|
311
|
-
contexts,
|
|
312
|
-
results: [],
|
|
313
|
-
lastCall: null,
|
|
314
|
-
},
|
|
315
|
-
mockClear: () => {
|
|
316
|
-
// Clear sinon internal data (the getters will now return empty arrays)
|
|
317
|
-
stub.resetHistory();
|
|
318
|
-
// Clear other mock tracking data that we manage directly
|
|
319
|
-
jestSpy.mock.instances = [];
|
|
320
|
-
jestSpy.mock.contexts = [];
|
|
321
|
-
jestSpy.mock.calls = [];
|
|
322
|
-
jestSpy.mock.results = [];
|
|
323
|
-
jestSpy.mock.lastCall = null;
|
|
324
|
-
return jestSpy;
|
|
325
|
-
},
|
|
326
|
-
mockReset: () => {
|
|
327
|
-
jestSpy.mockClear();
|
|
328
|
-
stub.resetBehavior();
|
|
329
|
-
return jestSpy;
|
|
330
|
-
},
|
|
331
|
-
mockRestore: () => {
|
|
332
|
-
if (stub.restore) {
|
|
333
|
-
stub.restore();
|
|
334
|
-
}
|
|
335
|
-
return jestSpy;
|
|
336
|
-
},
|
|
337
|
-
mockReturnValue: (value) => {
|
|
338
|
-
const returnWrapper = function (...args) {
|
|
339
|
-
contexts.push(this);
|
|
340
|
-
if (new.target) {
|
|
341
|
-
const instance = Object.create({});
|
|
342
|
-
instances.push(instance);
|
|
343
|
-
return value !== undefined ? value : instance;
|
|
344
|
-
}
|
|
345
|
-
return value;
|
|
346
|
-
};
|
|
347
|
-
stub.callsFake(returnWrapper);
|
|
348
|
-
return jestSpy;
|
|
349
|
-
},
|
|
350
|
-
mockReturnValueOnce: (value) => {
|
|
351
|
-
stub
|
|
352
|
-
.onCall(stub.callCount)
|
|
353
|
-
.callsFake(function (...args) {
|
|
354
|
-
contexts.push(this);
|
|
355
|
-
if (new.target) {
|
|
356
|
-
const instance = Object.create({});
|
|
357
|
-
instances.push(instance);
|
|
358
|
-
return value !== undefined ? value : instance;
|
|
359
|
-
}
|
|
360
|
-
return value;
|
|
361
|
-
});
|
|
362
|
-
return jestSpy;
|
|
363
|
-
},
|
|
364
|
-
mockResolvedValue: (value) => {
|
|
365
|
-
const promiseWrapper = function (...args) {
|
|
366
|
-
contexts.push(this);
|
|
367
|
-
if (new.target) {
|
|
368
|
-
const instance = Object.create({});
|
|
369
|
-
instances.push(instance);
|
|
370
|
-
return Promise.resolve(value);
|
|
371
|
-
}
|
|
372
|
-
return Promise.resolve(value);
|
|
373
|
-
};
|
|
374
|
-
stub.callsFake(promiseWrapper);
|
|
375
|
-
return jestSpy;
|
|
376
|
-
},
|
|
377
|
-
mockResolvedValueOnce: (value) => {
|
|
378
|
-
stub
|
|
379
|
-
.onCall(stub.callCount)
|
|
380
|
-
.callsFake(function (...args) {
|
|
381
|
-
contexts.push(this);
|
|
382
|
-
if (new.target) {
|
|
383
|
-
const instance = Object.create({});
|
|
384
|
-
instances.push(instance);
|
|
385
|
-
return Promise.resolve(value);
|
|
386
|
-
}
|
|
387
|
-
return Promise.resolve(value);
|
|
388
|
-
});
|
|
389
|
-
return jestSpy;
|
|
390
|
-
},
|
|
391
|
-
mockRejectedValue: (value) => {
|
|
392
|
-
const rejectWrapper = function (...args) {
|
|
393
|
-
contexts.push(this);
|
|
394
|
-
if (new.target) {
|
|
395
|
-
const instance = Object.create({});
|
|
396
|
-
instances.push(instance);
|
|
397
|
-
return Promise.reject(value);
|
|
398
|
-
}
|
|
399
|
-
return Promise.reject(value);
|
|
400
|
-
};
|
|
401
|
-
stub.callsFake(rejectWrapper);
|
|
402
|
-
return jestSpy;
|
|
403
|
-
},
|
|
404
|
-
mockRejectedValueOnce: (value) => {
|
|
405
|
-
stub
|
|
406
|
-
.onCall(stub.callCount)
|
|
407
|
-
.callsFake(function (...args) {
|
|
408
|
-
contexts.push(this);
|
|
409
|
-
if (new.target) {
|
|
410
|
-
const instance = Object.create({});
|
|
411
|
-
instances.push(instance);
|
|
412
|
-
return Promise.reject(value);
|
|
413
|
-
}
|
|
414
|
-
return Promise.reject(value);
|
|
415
|
-
});
|
|
416
|
-
return jestSpy;
|
|
417
|
-
},
|
|
418
|
-
mockImplementation: (fn) => {
|
|
419
|
-
// Update the wrapper to use the new implementation
|
|
420
|
-
const newWrapper = function (...args) {
|
|
421
|
-
contexts.push(this);
|
|
422
|
-
if (new.target && typeof fn === 'function') {
|
|
423
|
-
const instance = Object.create(fn.prototype || {});
|
|
424
|
-
instances.push(instance);
|
|
425
|
-
const result = fn.apply(instance, args);
|
|
426
|
-
return result !== undefined ? result : instance;
|
|
427
|
-
}
|
|
428
|
-
return fn.apply(this, args);
|
|
429
|
-
};
|
|
430
|
-
stub.callsFake(newWrapper);
|
|
431
|
-
return jestSpy;
|
|
432
|
-
},
|
|
433
|
-
mockImplementationOnce: (fn) => {
|
|
434
|
-
stub.onCall(stub.callCount).callsFake(fn);
|
|
435
|
-
return jestSpy;
|
|
436
|
-
},
|
|
437
|
-
// Convenience methods for Jest compatibility
|
|
438
|
-
toHaveBeenCalled: () => stub.called,
|
|
439
|
-
toHaveBeenCalledTimes: (expected) => stub.callCount === expected,
|
|
440
|
-
toHaveBeenCalledWith: (...args) => {
|
|
441
|
-
return stub
|
|
442
|
-
.getCalls()
|
|
443
|
-
.some((call) => call.args.length === args.length &&
|
|
444
|
-
call.args.every((arg, index) => arg === args[index]));
|
|
445
|
-
},
|
|
446
|
-
toHaveBeenLastCalledWith: (...args) => {
|
|
447
|
-
const calls = stub.getCalls();
|
|
448
|
-
if (calls.length === 0)
|
|
449
|
-
return false;
|
|
450
|
-
const lastCall = calls[calls.length - 1];
|
|
451
|
-
return (lastCall.args.length === args.length &&
|
|
452
|
-
lastCall.args.every((arg, index) => arg === args[index]));
|
|
453
|
-
},
|
|
454
|
-
toHaveBeenNthCalledWith: (nthCall, ...args) => {
|
|
455
|
-
const calls = stub.getCalls();
|
|
456
|
-
if (nthCall < 1 || nthCall > calls.length)
|
|
457
|
-
return false;
|
|
458
|
-
const call = calls[nthCall - 1];
|
|
459
|
-
return (call.args.length === args.length &&
|
|
460
|
-
call.args.every((arg, index) => arg === args[index]));
|
|
461
|
-
},
|
|
462
|
-
toHaveReturnedWith: (value) => {
|
|
463
|
-
return stub.getCalls().some((call) => call.returnValue === value);
|
|
464
|
-
},
|
|
465
|
-
toHaveLastReturnedWith: (value) => {
|
|
466
|
-
const calls = stub.getCalls();
|
|
467
|
-
if (calls.length === 0)
|
|
468
|
-
return false;
|
|
469
|
-
return calls[calls.length - 1].returnValue === value;
|
|
470
|
-
},
|
|
471
|
-
toHaveNthReturnedWith: (nthCall, value) => {
|
|
472
|
-
const calls = stub.getCalls();
|
|
473
|
-
if (nthCall < 1 || nthCall > calls.length)
|
|
474
|
-
return false;
|
|
475
|
-
return calls[nthCall - 1].returnValue === value;
|
|
476
|
-
},
|
|
477
|
-
toHaveReturnedTimes: (expected) => {
|
|
478
|
-
return (stub.getCalls().filter((call) => !call.exception).length === expected);
|
|
479
|
-
},
|
|
480
|
-
// Promise-specific helpers
|
|
481
|
-
toHaveResolvedWith: async (value) => {
|
|
482
|
-
const calls = stub.getCalls();
|
|
483
|
-
for (const call of calls) {
|
|
484
|
-
if (call.returnValue && typeof call.returnValue.then === 'function') {
|
|
485
|
-
try {
|
|
486
|
-
const resolved = await call.returnValue;
|
|
487
|
-
if (resolved === value)
|
|
488
|
-
return true;
|
|
489
|
-
}
|
|
490
|
-
catch {
|
|
491
|
-
// Promise rejected, skip
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
return false;
|
|
496
|
-
},
|
|
497
|
-
toHaveRejectedWith: async (value) => {
|
|
498
|
-
const calls = stub.getCalls();
|
|
499
|
-
for (const call of calls) {
|
|
500
|
-
if (call.returnValue && typeof call.returnValue.catch === 'function') {
|
|
501
|
-
try {
|
|
502
|
-
await call.returnValue;
|
|
503
|
-
// Promise resolved, skip
|
|
504
|
-
}
|
|
505
|
-
catch (error) {
|
|
506
|
-
if (error === value)
|
|
507
|
-
return true;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
return false;
|
|
512
|
-
},
|
|
513
|
-
mockReturnThis: () => {
|
|
514
|
-
const thisWrapper = function (...args) {
|
|
515
|
-
contexts.push(this);
|
|
516
|
-
if (new.target) {
|
|
517
|
-
const instance = Object.create({});
|
|
518
|
-
instances.push(instance);
|
|
519
|
-
return instance;
|
|
520
|
-
}
|
|
521
|
-
return this;
|
|
522
|
-
};
|
|
523
|
-
stub.callsFake(thisWrapper);
|
|
524
|
-
return jestSpy;
|
|
525
|
-
},
|
|
526
|
-
});
|
|
527
|
-
Object.defineProperty(jestSpy.mock, 'calls', {
|
|
528
|
-
get: () => {
|
|
529
|
-
return stub.getCalls().map((call) => call.args);
|
|
530
|
-
},
|
|
531
|
-
enumerable: true,
|
|
532
|
-
});
|
|
533
|
-
Object.defineProperty(jestSpy.mock, 'lastCall', {
|
|
534
|
-
get: () => {
|
|
535
|
-
const calls = stub.getCalls().map((call) => call.args);
|
|
536
|
-
return calls.length > 0 ? calls[calls.length - 1] : null;
|
|
537
|
-
},
|
|
538
|
-
enumerable: true,
|
|
539
|
-
});
|
|
540
|
-
Object.defineProperty(jestSpy.mock, 'results', {
|
|
541
|
-
get: () => {
|
|
542
|
-
return stub.getCalls().map((call) => {
|
|
543
|
-
if (call.exception) {
|
|
544
|
-
return { type: 'throw', value: call.exception };
|
|
545
|
-
}
|
|
546
|
-
return { type: 'return', value: call.returnValue };
|
|
547
|
-
});
|
|
548
|
-
},
|
|
549
|
-
enumerable: true,
|
|
550
|
-
});
|
|
551
|
-
return jestSpy;
|
|
552
|
-
};
|
|
553
|
-
export const spy = sinon.spy;
|
package/dist/rntl/userEvent.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ElementRef } from '@react-native-harness/interaction-engine';
|
|
2
|
-
export declare const userEvent: {
|
|
3
|
-
press: (elementRef: ElementRef, options?: Omit<{
|
|
4
|
-
elementRef: ElementRef;
|
|
5
|
-
}, "elementRef"> | undefined) => Promise<void>;
|
|
6
|
-
longPress: (elementRef: ElementRef, options?: Omit<{
|
|
7
|
-
elementRef: ElementRef;
|
|
8
|
-
}, "elementRef"> | undefined) => Promise<void>;
|
|
9
|
-
type: (elementRef: ElementRef, options?: Omit<{
|
|
10
|
-
elementRef: ElementRef;
|
|
11
|
-
text: string;
|
|
12
|
-
}, "elementRef"> | undefined) => Promise<void>;
|
|
13
|
-
clear: (elementRef: ElementRef, options?: Omit<{
|
|
14
|
-
elementRef: ElementRef;
|
|
15
|
-
}, "elementRef"> | undefined) => Promise<void>;
|
|
16
|
-
scroll: (elementRef: ElementRef, options?: Omit<{
|
|
17
|
-
elementRef: ElementRef;
|
|
18
|
-
direction: "up" | "down" | "left" | "right";
|
|
19
|
-
distance: number;
|
|
20
|
-
}, "elementRef"> | undefined) => Promise<void>;
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=userEvent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"userEvent.d.ts","sourceRoot":"","sources":["../../src/rntl/userEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACX,MAAM,0CAA0C,CAAC;AAkBlD,eAAO,MAAM,SAAS;wBAbN,UAAU;;;4BAAV,UAAU;;;uBAAV,UAAU;;;;wBAAV,UAAU;;;yBAAV,UAAU;;;;;CAmBzB,CAAC"}
|
package/dist/rntl/userEvent.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getClient } from './client.js';
|
|
2
|
-
const getUserEventAction = (actionType) => {
|
|
3
|
-
return (elementRef, options) => {
|
|
4
|
-
return getClient().rpc.executeAction({
|
|
5
|
-
type: actionType,
|
|
6
|
-
payload: {
|
|
7
|
-
elementRef,
|
|
8
|
-
...(options || {}),
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export const userEvent = {
|
|
14
|
-
press: getUserEventAction('press'),
|
|
15
|
-
longPress: getUserEventAction('longPress'),
|
|
16
|
-
type: getUserEventAction('type'),
|
|
17
|
-
clear: getUserEventAction('clear'),
|
|
18
|
-
scroll: getUserEventAction('scroll'),
|
|
19
|
-
};
|
package/dist/runner.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { TestSuite } from './collector/index.js';
|
|
2
|
-
import type { SuiteResult, BridgeEvents } from '@react-native-harness/bridge';
|
|
3
|
-
export type TestRunnerContext = {
|
|
4
|
-
testFilePath: string;
|
|
5
|
-
};
|
|
6
|
-
export declare function runSuite(suite: TestSuite, eventHandler: (event: BridgeEvents[keyof BridgeEvents]) => void, context: TestRunnerContext): Promise<SuiteResult>;
|
|
7
|
-
//# sourceMappingURL=runner.d.ts.map
|
package/dist/runner.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAEV,WAAW,EACX,YAAY,EACb,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAsKF,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,SAAS,EAChB,YAAY,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,MAAM,YAAY,CAAC,KAAK,IAAI,EAC/D,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CAmFtB"}
|