Skip to content

[🐛 Bug]: Better resolve dynamic imports in browser tests #12056

@christian-bromann

Description

@christian-bromann

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

latest

Mode

WDIO Testrunner

Which capabilities are you using?

n/a

What happened?

When running browser tests and importing CJS modules through Vite, it sometimes happen that we get the following error:

Error:  Test failed due to following error(s):
  - pr-eact.test.tsx: Failed to fetch dynamically imported module: http://localhost:39259/node_modules/.vite/deps/@testing-library_preact.js?v=60c2fbb0: TypeError: Failed to fetch dynamically imported module: http://localhost:39259/node_modules/.vite/deps/@testing-library_preact.js?v=60c2fbb0

Usually it resolves when reloading the page which is why we look for this error in the browser runner. However we have experienced in our build that sometimes even reloading doesn't resolve the issue.

What is your expected behavior?

The CJS transformation should work flawlessly, the error should not appear.

How to reproduce the bug.

Unskip this test and run it in CI.

Relevant log output

- pr-eact.test.tsx: Failed to fetch dynamically imported module: http://localhost:39259/node_modules/.vite/deps/@testing-library_preact.js?v=60c2fbb0: TypeError: Failed to fetch dynamically imported module: http://localhost:39259/node_modules/.vite/deps/@testing-library_preact.js?v=60c2fbb0

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

    Bug 🐛help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions