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');
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:
My temporary workaround to allow me to mock this method is to do this: