You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to replace apollo-datasource-rest with your library, but I'm struggling with mocking of the external communication:
import { MockAgent, setGlobalDispatcher } from 'undici';
const mockAgent = new MockAgent();
setGlobalDispatcher(mockAgent);
mockAgent.disableNetConnect();
...
const mockPool = mockAgent.get(BASE_URL);
...
mockPool.intercept({ path: '/v1/something', method: 'GET' }).reply(404, '');
...
const api = new MyAPI();
const result = await api.doSomething('aaa', 'bbb');
Above is failing because DataSource is successfully reaching to the unmocked REST resource and gets rejected with HTTP 401. I don't find mocking you use in your tests as best approach and would like to make the undici mocking work with apollo-datasource-http, though I might need some help with that. Any suggestions?
The text was updated successfully, but these errors were encountered:
@dmateiu Thank You for your reply, looks like you're right and I think this might be a use case example for docs! I till need to sort out ie. if I can ensure proper timeout was set on my request, etc. but this for sure unblocks future work!
I'm trying to replace
apollo-datasource-rest
with your library, but I'm struggling with mocking of the external communication:Above is failing because DataSource is successfully reaching to the unmocked REST resource and gets rejected with HTTP 401. I don't find mocking you use in your tests as best approach and would like to make the
undici
mocking work withapollo-datasource-http
, though I might need some help with that. Any suggestions?The text was updated successfully, but these errors were encountered: