Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest passes but xhr-mock logs the Jest expectation failure to console.error #112

Open
radiantshaw opened this issue Jun 26, 2021 · 0 comments

Comments

@radiantshaw
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant