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

The sendFile property is missing #301

Open
ChrisMBarr opened this issue Apr 26, 2024 · 2 comments
Open

The sendFile property is missing #301

ChrisMBarr opened this issue Apr 26, 2024 · 2 comments

Comments

@ChrisMBarr
Copy link

As mentioned before in issues #88 and #245 (which were both closed without resolving!) the sendFile method is missing from this implementation. The TypeScript typedefs say it is there, but it is not at runtime.

To reproduce in a Jest test:

import * as httpMock from 'node-mocks-http';

const res = httpMock.createResponse();
jest.spyOn(res, 'sendFile');
//               ^^^^^^^^  Property `sendFile` does not exist in the provided object

My temporary workaround to allow me to mock this method is to do this:

import * as httpMock from 'node-mocks-http';

export function createMockResponse() {
  const res = httpMock.createResponse();
  res.sendFile = () => {};
  return res;
}
import { createMockResponse } from '../test-helpers';

const res = createMockResponse();
jest.spyOn(res, 'sendFile');
@ChrisMBarr ChrisMBarr changed the title The snedFile property is missing The sendFile property is missing Apr 26, 2024
@eugef eugef added the bug label Apr 29, 2024
@eugef
Copy link
Owner

eugef commented Apr 29, 2024

Hi @ChrisMBarr thanks for reporting an issue.

This project heavily relies on contributors, so would be great if you can also submit a fix.

Copy link

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants