Closed jml6m closed 6 years ago
Getting error: TypeError: original_request(...).then is not a function
You’re correct — you’ve changed original_request(...)
to return an array;
injector({'request-promise': () => [{id: '12345'}]})
and are then trying to call .then
on it.
As for your SyntaxError
, I’d need more information to be able to assist you with that. Regardless I don’t think this is an error with inject-loader
itself, so I’m going to close this out unless you can manage to create a repro for me.
I have npm library request-promise and am importing as so at the top of a NodeJS file:
import * as original_request from 'request-promise';
Exported function that uses this as seen here:
In test file I am mocking out like this:
Getting error:
TypeError: original_request(...).then is not a function
I think I need to change the
request-promise
function ininjector
but I am not sure how to structure it. I've tried doing() => Promise.resolve([{id: '12345'}])
but that gives me error JavaScriptSyntaxError{}
(no information with it)