Skip to content

[Bug] toBeElementsArrayOfSize throws an error in some cases #2007

@cchangenot

Description

@cchangenot

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.23.2

Node.js Version

v24.13.0

Mode

Standalone Mode

Which capabilities are you using?

No response

What happened?

Upgrading expect-webdriverio from from 5.6.1 to 5.6.3 makes toBeElementsArrayOfSize throw an error in some cases:

TypeError: Cannot read properties of undefined (reading 'options')

What is your expected behavior?

No response

How to reproduce the bug.

describe("toBeElementsArrayOfSize", () => {
  it("should work", async () => {
    await browser.url("https://webdriver.io/");
    // throws TypeError: Cannot read properties of undefined (reading 'options')
    await expect($$("a.button")).toBeElementsArrayOfSize({gte: 1000});
  });
});

Note that using the correct value in the expectaction seem be working fine 🤷 :

describe("toBeElementsArrayOfSize", () => {
  it("should work", async () => {
    await browser.url("https://webdriver.io/");
    // works fine
    await expect($$("a.button")).toBeElementsArrayOfSize({gte: 4});
  });
});

Relevant log output

TypeError: Cannot read properties of undefined (reading 'options')

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

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