question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testcafe crashes with a js error when testing an app with a web worker implemented as a module

See original GitHub issue

What is your Scenario?

Testcafe should work without crashes when testing an app which uses a web worker as a module. A simplest example to that would be creating a worker (of module type) in the application’s main module. See steps below for more details.

What is the Current behavior?

Testcafe crashes with the following JavaScript error:

1) A JavaScript error occurred on "http://localhost:3000/".
      Repeat test actions in the browser and check the console for errors.
      To ignore client-side JavaScript errors, enable the "--skip-js-errors" CLI option, or set
      the "skipJsErrors" configuration file property to "true".
      If the website only throws this error when you test it with TestCafe, please create a new
      issue at:
      "https://github.com/DevExpress/testcafe/issues/new?template=bug-report.md".
      
      JavaScript error details:
      Uncaught TypeError: Failed to execute 'importScripts' on 'WorkerGlobalScope': Module
      scripts don't support importScripts().
          No stack trace available

What is the Expected behavior?

A test comes up green, and TestCafe doesn’t crash

What is your public website URL? (or attach your complete example)

testcafe_module_worker_issue-1.0.0.zip

What is your TestCafe test code?

import {Selector} from 'testcafe';

fixture('Test')
.beforeEach(t => t.navigateTo('http://localhost:3000/'));

test('module web worker should be supported', async t => {
  const text = await Selector('body p').textContent;
  await t.expect(text).eql('Some content which is irrelevant for the purpose of this demo');
});

Your complete configuration file

No configuration file has been used in the attached demo.

Your complete test report

Running tests in:

  • Chrome 97.0.4692.99 / macOS 10.15.7

Test ✖ module web worker should be supported

  1. A JavaScript error occurred on “http://localhost:3000/”. Repeat test actions in the browser and check the console for errors. To ignore client-side JavaScript errors, enable the “–skip-js-errors” CLI option, or set the “skipJsErrors” configuration file property to “true”. If the website only throws this error when you test it with TestCafe, please create a new issue at: “https://github.com/DevExpress/testcafe/issues/new?template=bug-report.md”.

    JavaScript error details: Uncaught TypeError: Failed to execute ‘importScripts’ on ‘WorkerGlobalScope’: Module scripts don’t support importScripts().     No stack trace available

    Browser: Chrome 97.0.4692.99 / macOS 10.15.7

1/1 failed (0s)

Screenshots

No response

Steps to Reproduce

  1. Unzip the attached demo (testcafe_module_worker_issue-1.0.0.tgz)
  2. Install the packages (npm i)
  3. Run a web server (npm run start-server)
  4. Run a sample e2e test (npm run e2e)

TestCafe version

1.18.2

Node.js version

v14.16.1

Command-line arguments

testcafe chrome main.ts

Browser name(s) and version(s)

Chrome 97.0.4692.99

Platform(s) and version(s)

macOS 12.1 (21C52)

Other

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
AlexKamaevcommented, Jan 27, 2022

Thank you for sharing the example with us. I was able to reproduce the issue. Please follow this ticket to track our progress.

1reaction
val1984commented, May 3, 2022

I had the same issue with an app using a webworker with Vite.js. The working solution is as follows:

import MyWorker from './Workers/index.js?worker&inline';
const worker = new MyWorker({ type: 'classic' });

The worker wasn’t working with testcafe until &inline was added to the import and the worker is not imported as a module nor as a different file as a result but it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration File | API | Docs
TestCafe tests fail when a page yields a JavaScript error. Use the skipJsErrors option to ignore JavaScript errors. Important. Errors are signs of...
Read more >
testcafe/CHANGELOG.md
98, Now when a JavaScript error occurs on the tested webpage, the test ... 188, * An error is no longer thrown when...
Read more >
Version History | TestCafe Studio
You can now ignore JavaScript errors in specific tests, fixtures, ... Studio to crash when users attempted to update the application.
Read more >
testcafe | Yarn - Package Manager
A Node.js tool to automate end-to-end web testing. ... not fit the visibility criteria, TestCafe outputs an error message that references the exact...
Read more >
Source - GitHub
Improvement: New ways to ignore JavaScript errors TestCafe v2.0 introduces new ways ... Fixed a crash that occurred in IE11 when Web Workers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found