twd-js 1.7.0 → 1.7.2
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/bundled.d.ts +3 -0
- package/dist/bundled.es.js +9856 -601
- package/dist/index.cjs.js +33 -33
- package/dist/index.d.ts +13 -10
- package/dist/index.es.js +1672 -1648
- package/dist/mock-sw.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -418,24 +418,27 @@ declare interface TWDAPI {
|
|
|
418
418
|
*
|
|
419
419
|
* @param callback Function to retry — can be sync or async. Should throw if the condition is not yet met.
|
|
420
420
|
* @param options Optional timeout, interval, and message settings
|
|
421
|
-
* @returns A promise that resolves
|
|
421
|
+
* @returns A promise that resolves with the callback's return value when it succeeds
|
|
422
422
|
*
|
|
423
423
|
* @example
|
|
424
424
|
* ```ts
|
|
425
|
-
* // Wait for an analytics event
|
|
426
|
-
* await twd.waitFor(() => {
|
|
427
|
-
* const
|
|
428
|
-
* expect(
|
|
425
|
+
* // Wait for an analytics event and return it
|
|
426
|
+
* const event = await twd.waitFor(() => {
|
|
427
|
+
* const ev = findEvent("purchase");
|
|
428
|
+
* expect(ev).to.exist;
|
|
429
|
+
* return ev;
|
|
429
430
|
* }, { message: "purchase event to fire" });
|
|
430
431
|
*
|
|
431
|
-
* // Wait
|
|
432
|
+
* // Wait for an element (single expression)
|
|
433
|
+
* const heading = await twd.waitFor(() => screenDom.getByRole("heading", { name: /checkout/i }));
|
|
434
|
+
*
|
|
435
|
+
* // Fire-and-forget (void) — still works as before
|
|
432
436
|
* await twd.waitFor(() => {
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
* }, { timeout: 5000 });
|
|
437
|
+
* expect(submitButton.disabled).to.be.false;
|
|
438
|
+
* });
|
|
436
439
|
* ```
|
|
437
440
|
*/
|
|
438
|
-
waitFor: (callback: () =>
|
|
441
|
+
waitFor: <T>(callback: () => T | Promise<T>, options?: WaitForOptions) => Promise<T>;
|
|
439
442
|
/**
|
|
440
443
|
* Asserts something about the element.
|
|
441
444
|
* @param el The element to assert on
|