Skip to content

[Feature]: arrayOf matcher #38067

@jfgreffier

Description

@jfgreffier

🚀 Feature Request

Adding a built-in arrayOf matcher would be a nice addition to generic assertions.

Example

An example from Jest documentation:

test('all elements in array are strings', () => {
  expect(['apple', 'banana', 'cherry']).toEqual(
    expect.arrayOf(expect.any(String)),
  );
});

Motivation

arrayOfis the only asymmetric matcher that exists in Jest's expect and not in Playwright. It can be useful for API tests, to ensure that an Object has an Array of "something".

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