webdriverio/webdriverio

[🐛 Bug]: Mock hoisting fails for direct imports

開放

#12,624 建立於 2024年4月3日

 (0 則留言) (0 個反應) (0 位負責人)JavaScript (1,793 個分叉)batch import
Bug 🐛help wanted

倉庫指標

星標
 (6,029 顆星)
PR 合併指標
 (平均合併 15天 15小時) (30 天內合併 48 個 PR)

描述

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 WebdriverIO is able to mock imports from dependent imports. This is possible by having it rewrite the chunk from:

import foo from 'bar'

to

import * as __wdioImport_0 from 'bar'
const { default: foo } = wdioImport('bar', __wdioImport_0)

However this fails if you import a module directly, e.g.

import 'bar'

What is your expected behavior?

Have it work in the same way as for other imports.

How to reproduce the bug.

Change this line: https://github.com/webdriverio/workshop/blob/main/solutions/chapter_13/src/todo-app.test.ts#L28 to a direct import and see the test failing.

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

貢獻者指南