zeromq / zeromq.js

:zap: Node.js bindings to the ØMQ library
http://zeromq.github.io/zeromq.js/
MIT License
1.47k stars 212 forks source link

Unexpected behavior when testing with Jest—disappearing instance methods #416

Open neezer opened 4 years ago

neezer commented 4 years ago

Describe the bug Method send on instance of zmq.Publisher vanishes on subsequent test runs in Jest with --watch --runInBand. The test passes on the first run, but subsequent runs fail with

● works always

    expect(received).toBe(expected) // Object.is equality

    Expected: function
    Received: undefined

The test passes on subsequent runs if the --runInBand flag is omitted.

Reproducing Using jest@25.2.7, define the following test:

const zmq = require("zeromq");

test("works always", async () => {
  const publisher = new zmq.Publisher();

  expect(typeof publisher.send).toBe("function");
});
  1. Run with jest path/to/above/test/file.js --watch with the --runInBand flag.
  2. Trigger multiple test runs without closing the test runner instance.

    Eg., hit the Enter key with the test runner focused

Expected behavior This test should always pass.

Tested on

ishantiw commented 3 years ago

@neezer do we have any update on this issue yet? Most of our tests in jest are quite unstable due to this issue, even if we runInBand, it doesn't work but running them individually works fine

neezer commented 3 years ago

@ishantiw No, sorry. I encountered this issue on a side project and haven't had time to return to it.

ptitjes commented 2 years ago

This already merged commit https://github.com/zeromq/zeromq.js/commit/4b3aad8faaafc4790cba18507f7194850e3f4d84 seems to fix the problem.

It would be great to have a 6.0.0-beta.7 or better a final version. The last 6.0.0 version is from the 17 Dec 2019!