Worker not defined when I try to run mocha test

Saba Hassan

I want to write test script to check whether Worker gets created in a function in some external file. The function I want to test is,

createPoller: function () {
  var poller = new Worker(POLLER_PATH),
      _this = this;


  /* worker handler on receiving the message */
  poller.onmessage = this.handlePoller.bind(_this);
  this.set('pollerId', U.generateUUID());
  this.set('poller', poller);
}
>>> ReferenceError: Worker is not defined
at new Worker(POLLER_PATH)
      ^

When I run the code, workers are created and they work fine. But when I run script on that particular code it says Worker is undefined.

Louis

If the JavaScript environment you use supports web workers natively, then they should just be there for you to use, and your code should work. So the most probable issue is that you are in fact running your code in a JavaScript environment that does not support web workers natively. If you want to use web workers in Node.js, for instance, you'd have to add a library that provides it. According to MDN, IE does not support web workers before version 10.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to run a single test with Mocha?

Run a simple test in Mocha

NullPointerException in RecyclerViewMatcher when try run my Espresso Test

Pythonw crashes when I try to run a file

Jenkins - Helm - Docker not found when try to run a test

When I run mocha tests in my project, it can't be terminated after test

when I try to Run Nuit 3 Test explorer : Getting Could not load file or assembly 'Tech Talk.Specrun.frame.Utils

Unit test fail when try run asset equals of array in Matomo

Mocha test not running the `try..finally` clause

My function works fine by itself but not when I run it as a worker

I am trying to run my test script using mocha but there is an error of "Reference Error: beforeEach is not defined"

When i try to run a discord bot it says that "message is not defined"

Pytest gives me an error when try to run a test

Mocha Testing Getting "getting 500 Unexpected JSON o in JSON at position 1" when I try to pass json object for test

Run a mocha test?

App crashes when i try to run this page

how to run a selenium test in mocha?

Build Failed when i try to run the app

Problems when I try to run npm

Can not test something with mocha when I have angular (1.6) as a dependency

Why does newer version of mocha not output test details when I run npm test?

Error on jest when I try to run the test

Mocha, "require is not defined" when test in browser

Roslyn crashes when I try to run a script

AssertionError when I try to write a unit test

Context eval expression when I write function in Mocha Test as lambda

IntelliJ IDEA: Can I run "green arrow" unit tests directly with Mocha, when both Karma and Mocha are installed?

Mocha passing test when i expect throw, but muy function is not throwing

pygames not working for python when I try and run it