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.

      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