Closed brijeshprasad89 closed 4 years ago
I think _getData()
is an async operation—I had this issue and resolved it by wrapping the call in a timeout. I admit it's not the best solution though.
If _getData()
is async, it would be nice if it returned a Promise.
https://github.com/howardabrams/node-mocks-http/issues/73 check this out, it works for me
I have got almost same issue, here's my code:
import { CategoryRouter } from '../../../routes/web';
import httpMocks from 'node-mocks-http';
function buildResponse () {
return httpMocks.createResponse();
}
describe('Category router', () => {
it('Returns 200 status code', () => {
const response = buildResponse()
const request = httpMocks.createRequest({
method: 'GET',
url: '/categories/',
});
CategoryRouter(request, response)
console.log('[Res:data]', response._getData());
});
});
It's a simple get router with sychronous code, no apis.
I get this error: TypeError: Cannot read property 'apply' of undefined
Anyone can help please?
Thanks in advance
Stale issue message
I have written the following code to fetch data from mondo db: Route:
controller:
mongoClient.findDataById(params, res);
client:
I am trying to write the integration test for the same:
I get nothing in
data
. Is there anything that I am doing wrong?