Skip to content

.single() should print the number of elements in its error message #210

@MartinHaeusler

Description

@MartinHaeusler

The .single() assertion is very useful and I use it a lot. However, if it fails, then it currently only prints that it was not fulfilled (the "x" mark). It would be nice if the failure message could distinguish the two cases where:

  • There were no elements in the subject collection
  • There was more than one element in the subject collection

In the second case, ideally the exact count should be printed too (something like "Expected 1 element, but found X"). It would be even better if the second case would also print the first two elements as examples (by simply calling toString() on them) as part of the failure message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions