webdriverio/webdriverio

[🐛 Bug]: Web worker failing tests

Open

#11.575 aperta il 2 nov 2023

Vedi su GitHub
 (5 commenti) (0 reazioni) (0 assegnatari)JavaScript (1793 fork)batch import
Bug 🐛help wanted

Metriche repository

Star
 (6029 star)
Metriche merge PR
 (Merge medio 15g 15h) (48 PR mergiate in 30 g)

Descrizione

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

^8.16.4

Node.js Version

v18.17.1

Mode

Standalone Mode

Which capabilities are you using?

No response

What happened?

Adding the usage of a web worker seems to break the test for a page that otherwise renders properly, here's the error:

[0-0] Unhandled error caught: Uncaught ReferenceError: wdioImport is not defined Uncaught ReferenceError: wdioImport is not defined [0-0] Global JS error caught: { message: 'Uncaught ReferenceError: wdioImport is not defined', source: 'http://localhost:54060/src/utils/ansi.ts', lineno: 2, colno: 18, error: null }

Here's a code snippet:

if (typeof Worker !== 'undefined') { const worker = new Worker( new URL('./ansiWorker.ts', import.meta.url), { type: 'module', } ) worker.onmessage = (event) => { setOutputHtml(event.data) }

What is your expected behavior?

Was hoping it would render the way that it does when just using hooks on and a function call.

How to reproduce the bug.

  • vite react typescript webapp
  • use a web worker to set a state variable in a component.
  • load the page with a test

Relevant log output

2023-11-02T04:57:05.776Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,./wdio.conf.mts,--spec,./src/tests/index.test.tsx
2023-11-02T04:57:09.311Z INFO @wdio/browser-runner:plugin: Received request for: /?cid=0-0&spec=/Users/adam/Projects/stateful/cloud/src/tests/index.test.tsx
2023-11-02T04:57:12.428Z INFO @wdio/browser-runner:ViteServer: Return command result: {"type":2,"value":{"id":"1","result":{"height":1080,"width":1920,"x":0,"y":40}}}
2023-11-02T04:57:47.174Z INFO @wdio/browser-runner:plugin: Received request for: /error?message=Uncaught%20ReferenceError%3A%20wdioImport%20is%20not%20defined
2023-11-02T04:57:47.224Z INFO @wdio/browser-runner:plugin: Received request for: /error?message=Uncaught%20ReferenceError%3A%20wdioImport%20is%20not%20defined

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

Guida contributor