Jest passes but xhr-mock logs the Jest expectation failure to console.error
radiantshaw opened this issue · 0 comments
radiantshaw commented
I have the following code:
import mock from "xhr-mock";
/**
* ... setup and teardown ...
*/
it("should make jest fail", function() {
expect.assertions(1);
mock.get("/", function(req, res) {
expect(true).toBe(false);
return res.status(200);
});
// ... send GET request to "/" ...
});
As expected, this should make Jest fail, but instead, Jest passes, and the following error is logged to console.error
:
xhr-mock: A handler returned an error for the request.
GET / HTTP/1.1
Error: expect(received).toBe(expected) // Object.is equality
Expected: false
Received: true
at /<path to test file folder>/test.js:LL:CC
at /<path to project home>/node_modules/xhr-mock/lib/createMockFunction.js:23:24
at /<path to project home>/node_modules/xhr-mock/lib/handle.js:24:24
at processTicksAndRejections (node:internal/process/task_queues:96:5)