zeromq.js icon indicating copy to clipboard operation
zeromq.js copied to clipboard

Unexpected behavior when testing with Jest—disappearing instance methods

Open neezer opened this issue 5 years ago • 3 comments

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 [email protected], 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

  • OS: macOS 10.15.6
  • ZeroMQ.js version: 6.0.0-beta.6

neezer avatar Aug 19 '20 16:08 neezer

@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

ishantiw avatar Sep 02 '21 10:09 ishantiw

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

neezer avatar Sep 02 '21 16:09 neezer

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!

ptitjes avatar Oct 06 '22 15:10 ptitjes