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/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 when the callback succeeds
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 event = findEvent("purchase");
428
- * expect(event).to.exist;
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 with custom timeout
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
- * const el = document.querySelector(".loaded");
434
- * if (!el) throw new Error("not loaded");
435
- * }, { timeout: 5000 });
437
+ * expect(submitButton.disabled).to.be.false;
438
+ * });
436
439
  * ```
437
440
  */
438
- waitFor: (callback: () => void | Promise<void>, options?: WaitForOptions) => Promise<void>;
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