Skip to content

[🐛 Bug]: Reduce function is not using the initial value parameter #14749

@Nyaran

Description

@Nyaran

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.19.2

Node.js Version

22.18.0

Mode

Standalone Mode

Which capabilities are you using?

{
    browserName: 'chrome'
}

What happened?

Using the .reduce function on a ChainablePromiseArray from $$ is not working properly as is not using the argument for initial value, using always the first found element

What is your expected behavior?

If the argument "initialValue" is specified, should be used

How to reproduce the bug.

git clone https://github.com/Nyaran/webdriverio-elements-reduce
cd webdriverio-cucumber-skip
npm i
npm run wdio

Relevant log output

There is no relevant log output really, just see how is working on the shared repository, but without fixing it the most relevant output is:

[0-0] TypeError in "My Login application.get inputs and filter using reduce"
TypeError: Cannot read properties of undefined (reading 'setValue')
    at Context.<anonymous> (./wdio-minefield/test/specs/test.e2e.ts:14:31)

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions