Documentation
    Preparing search index...
    • Validates pagination index API results against expected entity order.

      Compares the order of entities returned by a pagination API with manually sorted expected results. Validates that entity IDs appear in the correct sequence. Commonly used for testing database queries, search results, and any paginated data APIs.

      A page holds the first entities, so only the common prefix of the two lists is compared. An empty result against expected entities, or the reverse, fails.

      Type Parameters

      • X extends IEntity<any>
      • Y extends IEntity<any> = X

      Parameters

      • title: string

        Descriptive title used in error messages when order differs

      • expected: X[]

        The expected entities in correct order

      • gotten: Y[]

        The actual entities returned by the API

      • trace: boolean = false

        Optional flag to enable debug logging (default: false)

      Returns void

        // Test article pagination
      const expectedArticles = await db.articles.findAll({ order: 'created_at DESC' });
      const actualArticles = await api.functional.getArticles({ page: 1, limit: 10 });

      TestValidator.index("article pagination order", expectedArticles, actualArticles,
      true // enable trace logging
      );

      // Test user search results
      const manuallyFilteredUsers = allUsers.filter(u => u.name.includes("John"));
      const apiSearchResults = await api.functional.searchUsers({ query: "John" });

      TestValidator.index("user search results", manuallyFilteredUsers, apiSearchResults);

      Error when entity order differs between expected and actual results over their common prefix, or when exactly one of them is empty