twd-js 0.3.1 → 0.4.0

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.
@@ -45,6 +45,16 @@ export declare const initRequestMocking: () => Promise<void>;
45
45
  * ```
46
46
  */
47
47
  export declare const mockRequest: (alias: string, options: Options) => Promise<void>;
48
+ /**
49
+ * wait for a list of mocked requests to be made.
50
+ * @param aliases The aliases of the mock rules to wait for
51
+ * @returns The matched rules (with body if applicable)
52
+ * @example
53
+ * ```ts
54
+ * await waitForRequests(["getUser", "postComment"]);
55
+ * ```
56
+ */
57
+ export declare const waitForRequests: (aliases: string[]) => Promise<Rule[]>;
48
58
  /**
49
59
  * Wait for a mocked request to be made.
50
60
  * @param alias The alias of the mock rule to wait for
@@ -0,0 +1 @@
1
+ export declare const visit: (url: string) => Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function eventsMessage(prefix: string, prop: PropertyKey, args: any[]): string;
package/dist/twd.d.ts CHANGED
@@ -49,6 +49,20 @@ interface TWDAPI {
49
49
  *
50
50
  */
51
51
  get: (selector: string) => Promise<TWDElemAPI>;
52
+ /**
53
+ * Finds multiple elements by selector and returns an array of TWD APIs for them.
54
+ * @param selector CSS selector
55
+ * @returns {Promise<TWDElemAPI[]>} Array of TWD APIs for the elements
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const items = await twd.getAll(".item");
60
+ * items.at(0).should("be.visible");
61
+ * items.at(1).should("contain.text", "Hello");
62
+ * expect(items).to.have.length(3);
63
+ * ```
64
+ */
65
+ getAll: (selector: string) => Promise<TWDElemAPI[]>;
52
66
  /**
53
67
  * Simulates visiting a URL (SPA navigation).
54
68
  * @param url The URL to visit
@@ -96,6 +110,16 @@ interface TWDAPI {
96
110
  * ```
97
111
  */
98
112
  waitForRequest: (alias: string) => Promise<Rule>;
113
+ /**
114
+ * wait for a list of mocked requests to be made.
115
+ * @param aliases The aliases of the mock rules to wait for
116
+ * @returns The matched rules (with body if applicable)
117
+ * @example
118
+ * ```ts
119
+ * const rules = await waitForRequests(["getUser", "postComment"]);
120
+ * ```
121
+ */
122
+ waitForRequests: (aliases: string[]) => Promise<Rule[]>;
99
123
  /**
100
124
  * URL-related assertions.
101
125
  *