webdriverio / webdriverio/expect-webdriverio

Support of `arrayContaining`

Open
#2,004 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
86
Forks
61
Avg merge
19h 12m
Merged PRs (30d)
15

Description

Today, arrayContaining is not working with toHaveText and $$()

When doing the below, it fails

await expect(await $$('label')).toHaveText(expect.arrayContaining(['Username', 'Password']));
Expect $$(`label`) to have text

- Expected  - 2
+ Received  + 0

  Array [
-   ArrayContaining [
    "Username",
    "Password",
-   ],
  ]

While explicitly extracting text and doing equal works

        const texts = await $$('label').map( async (el) => el.getText())
        expect(texts).toEqual(expect.arrayContaining(['Username', 'Password']));

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported example with toHaveText, $$(), and expect.arrayContaining, then trace the assertion handling for array results. Compare it with the direct toEqual example; done means arrayContaining(['Username', 'Password']) works with the reported WebdriverIO element collection without breaking existing text assertions.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.