zeromq.js
zeromq.js copied to clipboard
Unexpected behavior when testing with Jest—disappearing instance methods
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");
});
-
Run with
jest path/to/above/test/file.js --watchwith the--runInBandflag. -
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 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 No, sorry. I encountered this issue on a side project and haven't had time to return to it.
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!