Skip to content

auto cleanup will break down testing in mocha & esm environment #375

Closed
@DaveWelling

Description

@DaveWelling
  • react-hooks-testing-library version: 3.2.1
  • react-test-renderer version: 16.9.0
  • react version: 16.13.1
  • node version: 10.13.0
  • npm (or yarn) version: 6.9.0

Relevant code or config:

The problem is exactly this:
testing-library/react-testing-library#614
but with this package instead of the react-testing-library
And the solution is the exactly the same (I tested it by hacking the node_modules).

Go into the flush-microtasks.js file and literally change this:
enqueueTask = nodeRequire('timers').setImmediate;
to this:
enqueueTask = nodeRequire.call(module, 'timers').setImmediate

What you did:

Run any mocha test using the react-hooks-testing-library and using esm.

What happened:

The library hangs the mocha tester if you are using esm.

Reproduction:

Run any test at all with this library, mocha and esm.

Problem description:

You get this error message (from flush-microtasks.js):
This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.'

It hangs the cleanup (for instance mocha afterEach will never finish).

Suggested solution:

Go into the flush-microtasks.js file and literally change this:
enqueueTask = nodeRequire('timers').setImmediate;
to this:
enqueueTask = nodeRequire.call(module, 'timers').setImmediate

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions