Skip to content

[Feature]: Order-Insensitive Collection Assertions #1876

@gamestheory

Description

@gamestheory

🚀 Feature Request

The hasText(String[] expected) assertion is strictly order-dependent. However, many UI components (like tags, filter chips, or list items) might appear in a non-deterministic order or the order might be irrelevant to the test case.

Example

Add a param to HasTextOptions or a new method to ignore order: hasText(String[] expected, boolean ignoreOrder) or hasTextInAnyOrder(String[] expected).

Motivation

Resilience to Change: Tests won't fail due to minor UI sorting changes that do not affect business logic.
Cleaner Test Code: Developers won't need to manually fetch, sort, and compare lists, which often bypasses Playwright's automatic retries.
Implementation: This can be implemented by internally sorting both the actual and expected collections before comparison when the flag is set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions