webdriverio/webdriverio

[🐛 Bug]: Mock factory module parameter has an invalid type

Open

#12,625 opened on Apr 3, 2024

View on GitHub
 (0 comments) (0 reactions) (0 assignees)JavaScript (1,793 forks)batch import
Bug 🐛help wanted

Repository metrics

Stars
 (6,029 stars)
PR merge metrics
 (Avg merge 15d 15h) (48 merged PRs in 30d)

Description

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

LTS

Mode

WDIO Testrunner

Which capabilities are you using?

n/a

What happened?

When running component tests in WebdriverIO, users can partially mock a module like:

mock('./foo-bar-baz.js', async (originalModule) => {
    // Mock the default export and named export 'foo'
    // and propagate named export from the original module
    return {
        __esModule: true,
        ...originalModule,
        default: fn(() => 'mocked baz'),
        foo: 'mocked foo',
    }
})

It seems though that the type for originalModule is wrong and defined as () => Promise<originalModule>.

What is your expected behavior?

Fix the type.

How to reproduce the bug.

n/a

Relevant log output

n/a

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

Contributor guide